Manfred Stienstra
manfred.stienstra at dwerg.net
Tue Jan 11 18:14:36 EST 2005
On Tue, 2005-01-11 at 16:23 -0500, Chris Jackson wrote: > My goal is to allow the creation of multiple, separate sessions, as > well as create global variables which all sessions have access to. > I'm having trouble understanding how to use mod_python.Session even > after looking at the available documentation. In particular, i'm > concerned with where to put "sess = Session(req)." Somewhere in your handler, but not outside the handler function. > I'm a little fuzzy on the memory space or variable scoping. Apache > runs multiple threads, and there's a single embedded python > interpreter. When multiple requests from different locations hit my > mod_python page, all these requests get processed under the same > interpreter? I want to use sessions because I think some of the data > is being overlapped/shared between different requests, but I want data > to be rationed out in sessions and some data still shared between > sessions such as a database connection object. Depending on what type of apache configuration you run, one or more interpreters will be used. Sometimes interpreters die and new ones get created. The general assumption is dat you will never get the same interpreter. If you want to keep objects on an interpreter, you have to create them in the scope of the interpreter (so outside any functions). Word of caution: don't put things like file objects or database objects in the session object. You never know when someone created a new request, so that object might not be valid any more. More on this: http://www.modpython.org/FAQ/faqw.py?req=show&file=faq03.018.htp For your database needs: http://www.modpython.org/FAQ/faqw.py?req=show&file=faq03.003.htp
|