[mod_python] Storing functions in session ?

Erik Stephens mod_python at 24ksoftware.com
Mon Mar 8 12:13:36 EST 2004


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

> I was wondering if it is possible to store functions within the
> session. I am playing around with writing a Python web IMAP
> client. I have been using the imaplib.IMAP4 library. The reason I
> ask, is once I create a connection to the IMAP server, I would like
> to keep it for any other commands. Thus I do not have to keep
> logging in, everytime I need to run an IMAP command.

Pickling something like a connection to a server seems odd.  Not sure
it's really possible the way you describe it.  You could pickle all of
the connection information but not the connection itself.  By
connection, I'm referring to the underlying network connection, not
the Python object that is abstracting that.  You could maybe get that
IMAP4 instance to pickle by overriding some hooks or something, but to
avoid dangling connections you would want to disconnect from the
server when pickling and re-connect when unpickling which doesn't seem
what you are striving for.

Note: this is kinda off the top of my head about what I know about
pickling/serialization in general, which I'm assuming is part of the
session handling interface and which I'm no expert :)


Best regards,
Erik



More information about the Mod_python mailing list