[mod_python] how do i share variables accross requests?

R. Pelizzi r.pelizzi at virgilio.it
Thu Aug 26 17:12:37 EDT 2004

You probably have encountered this feature in other application 
frameworks... i remember i was using it in ASP, it was called the 
Application Object. You could store variables (ints, strings, objects) 
in it and every request could read and write them thread-safely. A 
simple example using this feature would be a user-online counter.
Every request would check if the session is new. If it is, increment the 
counter and register a cleanup function for the session to decrement it.
Now, how do i implement it in python?
global variables, as far as i've understood, are not global to the 
server, just to the child process spawned by the server, so they cannot 
be used.
Do i really have to pickle what i want to share and write it on disk 
using dbm, mysql or such? Wouldn't this be terribly inefficient, 
pickiling and unpickling every request?
Does anybody have already implemented something similar and can post the 

Thank you

More information about the Mod_python mailing list