[mod_python] persistent values

Sean Reifschneider jafo at tummy.com
Mon Jun 23 15:30:27 EST 2003

On Sun, Jun 22, 2003 at 07:20:13PM -0500, Dustin Mitchell wrote:
>  config_parser = req.cp
>works like a charm.  Just be careful not to create a reference loop (e.g.,
>don't let the config parser have a reference to req buried inside of it..).

I didn't realize that you could set values on the request...
Unfortunately, in my case I am calling into the SimpleTAL code and that
is calling back into my code, by which point I no longer have access to
the request object.

One of the weirdnesses I've found about mod_python is that it seems to
be losing values that I set on module-level name-spaces.  If I import a
module, set a value on it, then later try to access it, sometimes it
works and sometimes it doesn't.  This may or may not be related to the
weirdness about how mod_python imports modules or PythonAutoReload...

I've finally just broken down and set up an object in __builtins__ that
I store request-related data on (including a link to the request and
other information).  I hate doing it this way, but it has allowed me to
reliably set and get data that I need to get access to.

 If we don't survive, we don't do anything else.
                 -- John Sinclair
Sean Reifschneider, Member of Technical Staff <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995.  Qmail, Python, SysAdmin

More information about the Mod_python mailing list