[mod_python] Session confusion

Jim Gallacher jpg at jgassociates.ca
Tue Feb 27 14:29:20 EST 2007


David Kramer wrote:
> David Kramer wrote:
>> 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 
>> production-ready.
>>
>> 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 cannot?
>>
>> 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
>> http://www.modpython.org/live/current/doc-html/pyapi-sess.html
>> 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.
> 
> I neglected to mention that, since this is an older app, we're using 
> Python 2.3 and mod_python 3.1.3 and MySQLdb 1.2.0, under Red Hat 
> Enterprise 4.0.

I know this may not be possible, but you should consider upgrading to 
3.3.1. There have been a huge number of fixes and improvements since 
3.1.3, including the plugging of a bunch of memory leaks. Those fixes 
alone make the upgrade worthwhile in a production environment.

Jim


More information about the Mod_python mailing list