[mod_python] SetEnv and add_common_vars()

Edwin Grubbs egrubbs at rackspace.com
Sun Jan 11 20:58:02 EST 2004


On Fri, Jan 09, 2004 at 07:48:39PM -0500, Gregory (Grisha) Trubetskoy wrote:
> 
> On Fri, 9 Jan 2004, Edwin Grubbs wrote:
> 
> > When I use SetEnv in my apache conf file, it causes a lot of the
> > environment variables (such as DOCUMENT_ROOT) to disappear that
> > add_common_vars() normally would set.
> 
> When you say "dissapear" - what are you using to look them up?

I am accessing the environment through the req.subprocess_env
dictionary.

> > The only workaround I have is to put the SetEnv statements in a
> > different <Directory> block than the directory with the files served by
> > mod_python.
> 
> What is the objective here? If you are you trying to pass information to
> mod_python from the config, a better way is to use PythonOption.

The objective is to access the environment variables that are unique to
each request such as REMOTE_ADDR, HTTP_USER_AGENT, and our own cookies
such as SESSION_COOKIE.

Here is the full list of environment variables that disappear from
req.subprocess_env when you use SetEnv in the apache conf in the same
<Directory> config block.

    DOCUMENT_ROOT=/home/egrubbs/work/project1/html
    HTTP_ACCEPT=text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
    HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7
    HTTP_ACCEPT_ENCODING=gzip,deflate
    HTTP_CACHE_CONTROL=max-age=0
    HTTP_CONNECTION=keep-alive
    HTTP_COOKIE=supmark=0-1031685007537-yes;
    supvid=1031685007537-15062133204827238; COOKIE_last_login=egrubbs;
    SESSION_COOKIE=a746faf7b134269514ebfb1e5edbfa1d; COOKIE_last_login=egrubbs; supbid=0; admin_session=979728667
    HTTP_HOST=dev.rackspace.com
    HTTP_KEEP_ALIVE=300
    HTTP_USER_AGENT=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031107 Debian/1.5-3
    PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
    REMOTE_ADDR=10.1.104.206
    REMOTE_PORT=38121
    SCRIPT_FILENAME=/home/egrubbs/work/project1/python/app/test.pt
    SERVER_ADDR=10.1.15.47
    SERVER_ADMIN=root at localhost
    SERVER_NAME=dev.rackspace.com
    SERVER_PORT=80
    SERVER_SIGNATURE=Apache/1.3.20 Server at dev.rackspace.com Port 80
    SERVER_SOFTWARE=Apache/1.3.20 (Unix)  (Red-Hat/Linux) mod_fastcgi/2.2.12 mod_python/2.7.6 Python/2.2.2 DAV/1.0.3 PHP/4.2.2


Thanks,
Edwin


More information about the Mod_python mailing list