[mod_python] SetEnv and add_common_vars()

Michael C. Neel neel at mediapulse.com
Mon Jan 12 17:05:01 EST 2004


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

> -----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
> 



More information about the Mod_python mailing list