[mod_python] Session confusion

David Kramer dkramer at aptima.com
Tue Feb 27 13:10:02 EST 2007

Hi.  I'm pretty new to mod_python.  I'm porting a mod_python program 
from Windows to Linux, and ran into the problem I posted a week or so 
ago, where under Windows, all the variables automatically persisted (due 
to Apache being one process under Windows), and the program was written 
to expect that.  I'm trying to store and recall the data using a 
session, but I'm having some strange problems, and some questions.

The biggest problem is that on occasion, when I call
    sess = Session.Session(req)
the program just halts and never returns from that line.  No errors in 
/var/log/htttpd/error_log, and the page times out.  What can cause that? 
  I can often get the program working again by deleting any cookies 
created by it, then restarting Apache, but that's not exactly 

I wrote a small test program that tries to create an instance of a small 
class and store that in the session data, and that seems to work (though 
I've never worked in a web evironment where you could store objects in 
cookies without somehow serializing them yourself).  Is that really the 
case?  Is there some rule about what can be stored in sessions and what 

Is there a way for me to see the contents of session data on the server? 
  I tried following the code in the Session module, but I'm not sure 
where or in what format the data is stored.  I'm guessing "dbm" is a 
Berkeley database that gets stored in a file somewhere, so I should be 
able to query it somehow.  I read somewhere that the stored data is 
pickled, so I'll have to write a Python program to display it, which 
shouldn't be a problem.

Lastly, I found the Session documentation "rather lacking" at
Are there any mod_python tutorials or examples or other docs that could 
help me?  I would love to RTFM, but I think I need a better FM.

Thanks in advance.

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

More information about the Mod_python mailing list