[mod_python] Session managment for mod_python

Ben Leslie benno at sesgroup.net
Mon Oct 16 08:46:55 EST 2000

On Sun, 15 Oct 2000, Gregory Trubetskoy wrote:

> On Sun, 15 Oct 2000, Damjan wrote:
> > > what do you mean by session management?
> > > 
> > The best session managment would be a Python dictionary, that is global
> > to all subinterpreters, and all Apache processes, and that retains its
> > state across handlers and requests.
> Let me guess - if Apache process is restarted, you would like the state to
> be retained througout the restart?

I would count it as dynamic data that can be lost. I am thinking this thing
would be great as a cache mainly for expensive database lookups, caching files
into memory for faster loading.

> > Let me illustrate what can be done with this. 
> [snip]
> > Of course you could do this with a database and pickle-ing the user
> > object. Or you could do this with a shared memory.
> I think you answered your own question - this sort of thing is best done
> with a database.
> I see Apache (and mod_python, which is just an interface to it) as a
> process responsible for serving requests, but not a database, data storage
> is not one of its functions, and it is well suited for delegating that
> function to a database. 

Data storage no, caching yes.

> If you think about it carefully, there is a slew of issues one has to
> consider to implement something like this. Locking alone could be pretty
> complicated. Why bother with any of this, if something like MySQL already
> does all of those things very efficiently.

There are a lot of issues, however squeezing some more performance out of
my application by caching files and the like would be extremely useful.
The question is the implemenation, afaict apache does not have a global shared
memroy by default, although there seems to be optional patches that can be
compiled in to give you access to to this memory, from what I can tell if we
had access to this interface it would be possible to create a global dictionary
in mod_python to suppport this. Is it worth creating extensions to mod_python
which rely on patches to the apache core?

If anyone with more apache experience than i have could make any comments I would
appreciate it.


Ben Leslie

More information about the Mod_python mailing list