[mod_python] Storing functions in session ?

Erik Stephens mod_python at 24ksoftware.com
Mon Mar 8 14:03:43 EST 2004


On Mon, 8 Mar 2004, SAiello at Jentoo.com wrote:

> Well storing the function seemed kinda wrong. I just do not know if
> there is any way to open a connection, and leave that connection
> open for use later on. Not to sure on the jargon, almost like
> pooling connections to a database.  Only problem is each connection
> is for a particular user, and you would never want them to get mixed
> up, otherwise someone would be reading someone else's email. Any
> ideas or suggestions are welcomed.

So, it sounds like you want a global object to be able to "serve" the
already opened connections to the different Apache threads or
processes (depending on your Apache implementation).  With a threaded
implementation, it *should* be as easy as creating a global hash/dict
keyed by user id or email address.  I've never done this, that's why I
say "should".  I'll be doing something along those lines soon enough
though.  You'll just have to take care that the threads don't step on
eachother when accessing that shared hash.

For a forking Apache implementation, it's beyond my abilities to see
how to do it.  I was just reading in Eric Raymond's "The Art of Unix
Programming" why multi-threaded programs are worse than per-process
ones.  I have to disagree, at least in this domain.


Best regards,
Erik



More information about the Mod_python mailing list