Jean Martin
jombo at 2wire.ch
Thu Aug 26 23:33:24 EDT 2004
Hi, Yes, ASP application object is nice, if you would like to cache some data. I go trought the same problem, and i finally choose the HEAP type table (in memory) of MySQL to store some strings i need, and do something similar. This have the advantage to be faster than a disk table, and not dependent of Apache. But if mysql is restarted for any reason, you have to recreate table... I hope this help Jean Martin -----Original Message----- From: mod_python-bounces at modpython.org [mailto:mod_python-bounces at modpython.org]On Behalf Of R. Pelizzi Sent: jeudi, 26. aout 2004 18:13 To: mod_python at modpython.org Subject: [mod_python] how do i share variables accross requests? 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? Thank you Riccardo _______________________________________________ Mod_python mailing list Mod_python at modpython.org http://mailman.modpython.org/mailman/listinfo/mod_python
|