[mod_python] SetEnv and add_common_vars()

Edwin Grubbs egrubbs at rackspace.com
Mon Jan 12 16:41:19 EST 2004


On Mon, Jan 12, 2004 at 05:05:01PM -0500, Michael C. Neel wrote:
> IIRC (and it's been a while) the "env's" everyone is used to are part of
> the CGI spec, and don't apply outside of it though often it will be
> recreated.  mod_perl has a function you can call to setup the standard
> env that a cgi script would have, but as Grisha pointed out it isn't the
> best use of resources.
> 
> Look though the docs on the request, server, and connection objects.
> Between those is everything you need to create the env's you are looking
> for.  REMOTE_ADDR and SCRIPT_NAME are not client headers, so that's why
> you don't see them in headers_in.
> 
> I'd recommend downloading Sam Spade for Windows from samspade.org, it
> has a browser in it that shows you exactly the information being passed
> between the client and server.
> 
> HTH,
> Mike

Grisha was pointing out that req.headers_in could be used in place of
req.subprocess_env for accessing the variables I needed. req.headers_in
only provided a few of the variables I needed, so I was writing back to
see if there was another method for retrieving these vars.

Earlier in the thread, you can read about how add_common_vars() fails to
add the standard CGI variables when SetEnv is used in the apache conf
file.

-Edwin

> 
> > -----Original Message-----
> > From: Edwin Grubbs [mailto:egrubbs at rackspace.com] 
> > Sent: Monday, January 12, 2004 4:37 PM
> > To: Gregory (Grisha) Trubetskoy
> > Cc: mod_python at modpython.org
> > Subject: Re: [mod_python] SetEnv and add_common_vars()
> > 
> > 
> > On Sun, Jan 11, 2004 at 11:27:12PM -0500, Gregory (Grisha) 
> > Trubetskoy wrote:
> > > 
> > > On Sun, 11 Jan 2004, Edwin Grubbs wrote:
> > > > 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.
> > > >
> > > 
> > > Hmm... This may be a bug somehwere, I'll have to take a 
> > look at it. But,
> > > all of this information is available directly without having to use
> > > subprocess_env, as part of the request object or req.headers_in.
> > > Subprocess_env is an inefficient way of doing it since it 
> > is artificially
> > > constructed from the same sources to which mod_python 
> > allows you direct
> > > access.
> > > 
> > > Grisha
> > 
> > The req.headers_in variable does not contain the REMOTE_ADDR or the
> > SCRIPT_NAME variables which can not be passed in using PythonOption.
> > 
> > -Edwin
> > _______________________________________________
> > Mod_python mailing list
> > Mod_python at modpython.org
> > http://mailman.modpython.org/mailman/listinfo/mod_python
> > 

-- 
In case you have sensitive data to send, here is my PGP key:
http://pgp.mit.edu:11371/pks/lookup?op=vindex&search=0xEADFF951


More information about the Mod_python mailing list