[mod_python] how do i share variables accross requests?

Jean-Philippe Barrette-LaPierre jpbarrette at savoirfairelinux.net
Thu Aug 26 11:33:57 EDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On August 26, 2004 12:12 pm, R. Pelizzi wrote:
> 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
> code?

for session management see:
   http://www.modpython.org/live/current/doc-html/pyapi-sess.html 
for "persistance" accross sessions see:
   http://www.modpython.org/live/current/doc-html/pyapi-cookie.html
>
> Thank you
> Riccardo
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

- -- 
Jean-Philippe Barrette-LaPierre
Maintener of curlpp
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBLfTV4k/6r/h0g7kRAoO/AKCsSlIbqtkU3nqL+K1reyC+sgIxZACgjGbv
YW9RJDfSQ9fXFxdsiizhmEE=
=rs67
-----END PGP SIGNATURE-----



More information about the Mod_python mailing list