[mod_python] Date persistence accross connections.

Stefan C. Kremer skremer at q.cis.uoguelph.ca
Thu Feb 13 21:14:03 EST 2003


Thanks for the reply Greg.  Actually I'm in the process of writing my own
session management tool (I looked at a few others and none of them really
suited my needs; plus I wanted to do it myself for the learning
experience).  So now I'm trying to figure out what my options are for
implementing persistent data.  Right now I'm identifying my session by
means of a cookie, so that part's not a problem.  My challenge now is, how
to associate more data with the cookie (session) in a way that persists
accross http requests.

The three options I'm working with right now are:

(1) just store in the info in the global namespace, keyed on the cookie.  
This seems to me to be the simplest, and fastest solution.  The drawbacks
are that queries that go to a different process won't have access to my
data.  Now that httpd is threaded, this happens much less often. In fact,
it seems to only occur when I explicitly restart apache or reboot my 
machine (which is basically never since I don't run Windows and have a 
UPS).

(2) Save it to a file.  This is slow, but otherwise would work fine if I 
implement appropriate file locking.

(3) Send it via a socket to another process which all mod_python processes 
share.

(4) Some combination of (1) with (2 or 3), which writes the data away and 
only retrieves it from (2,3) if its not in the local namespace.  I'm not 
sure how much I will gain from not retrieving data from (2,3) most of the 
time.

Are there any good options which I have overlooked?  Does my evaluation of
the alternatives seem sound?  Any suggestions or comments.

Thanks for any advice anyone wants to pass my way.

	-SK

 On Thu, 13 Feb 2003, Gregory Bond wrote:

> 
> skremer at q.cis.uoguelph.ca said:
> > So should I be able to just store a variable in my local namespace and
> >  then return to it the next time I make an http connection?  Or might
> > my  next connect be executing python in a different namespace for some
> >  reason?!? 
> 
> It might work in certain restricted circumstances, but it's likely to be 
> unreliable.  You can't know when Apache will decide it's time for a new 
> process.  You can't know when the apache process gets re-configured or 
> restarted.  You can't know when another unrelated session to the same 
> application will begin. 
> 
> You would be much better off to look at some of the session management tools
> that work with mod_python and handle the problem properly.  I use Albatross
> (http://www.object-craft.com.au/projects/albatross/) but that does a whole 
> heap more than just session management.  Others have recommended PSO 
> (http://www.scriptfoundry.com/modules/pso/).
> 
> Greg.
> 
> 
> 

-- 
--
Dr. Stefan C. Kremer, Associate Prof.
Reynolds Building, 106
Dept. of Computing and Information Science
University of Guelph, Guelph, Ontario	N1G 2W1

WWW: http://q.cis.uoguelph.ca/~skremer
Tel: (519)824-4120 Ext.58913  Fax: (519)837-0323
E-mail:  skremer at uoguelph.ca




More information about the Mod_python mailing list