[mod_python] persistent, reliable globals

David Geller dg at sponsera.com
Tue Mar 9 14:50:04 EST 2004


Hi,

Well, I had more or less come to this conclusion for the current
mod_python version. Thankyou.

Suggestion:
Perhaps what would be handy: a special python function call, implemented
via the API, to allow setting/getting of objects global to all the
forked children for a particular named interpreter. These objects might 
be accessible through the req
object, for example. I don't know enough to judge...

Is this feaible? Useful (well, it would be to me...)? Easy/hard?

Regards,
David

Erik wrote:

>On Mon, 8 Mar 2004, David Geller wrote:
>
>  
>
>>I would like to set a global variable (in memory) from a module. I would
>>then like to access this same global variable susequently by other
>>modules at any other time, and have the value that was set there to be
>>there (until, of course, Apache is restarted).
>>
>>I have tried several ways of doing this, and it doesn't seem to be
>>reliable - i.e., sometimes the global variable is set when I look at it,
>>and sometimes it is still at its original state.
>>
>>What am I doing wrong (or right)?
>>    
>>
>
>Greetings,
>
>New to the list and mod_python in general, but it sounds like you will
>only be able to pull this off if you are using a threaded Apache.
>Again, I'm new so I could be wrong.
>
>If you're stuck with a forked Apache, then you could try using
>something from the IPC toolbox: shared files, shared memory, messages,
>etc.  I would pickle whatever you wanted shared to some temp file and
>have your code check for that file and define it if does not exist.
>That approach has some dangerous aspects to it.  The threaded Apache
>approach sounds much better.
>
>
>Best regards,
>Erik
>_______________________________________________
>Mod_python mailing list
>Mod_python at modpython.org
>http://mailman.modpython.org/mailman/listinfo/mod_python
>
>  
>

-- 
David Geller
Sponsera, LLC
dg at sponsera.com
www.sponsera.com
Phone: 703.532.6812
Fax: 703.532.6058






More information about the Mod_python mailing list