[mod_python] Re: mod_python not very smart about EGG_CACHE path

Graham Dumpleton graham.dumpleton at gmail.com
Sat Jan 24 09:25:26 EST 2009


2009/1/24 Joshua Kugler <joshua at joshuakugler.com>:
> Joshua Kugler wrote:
>> Is there a way to get the children
>> to "reinitialize" this setting so they write to the correct egg cache
>> directory?
>
> I tried a SetEnv directive in the server configuration, but mod_python
> doesn't seem to honor it.  Still being told that the egg cache path
> is /root/.python-eggs

That will not work as the Apache SetEnv directive only sets
environment variables for CGI script processes which are execed from
Apache child worker processes.

The only way that SetEnv set values are available to mod_python is by
querying req.subprocess_env.

If you are not bound to mod_python specific APIs and are instead using
a Python web application/framework that supports WSGI, such as Django,
Trac etc., then don't use mod_python. Instead use mod_wsgi.

The mod_wsgi package has a proper understanding of Python egg cache
and has a directive for overriding its location in embedded mode
(equivalent to mod_python), or its daemon mode (similar to fastcgi).

When using mod_wsgi daemon mode, the value of HOME will also be set
correctly for the user that daemon process runs as, meaning that
overriding location of Python egg cache wouldn't even normally be
needed. This is not done for embedded mode as doing so could break
other stuff running in embedded mode as it would change the existing
behaviour of how Apache works.

So, use mod_wsgi unless you have a very good reason for still using mod_python.

Graham


More information about the Mod_python mailing list