[mod_python] The Session problem with mod_python3.2.7

Graham Dumpleton grahamd at dscpl.com.au
Tue Feb 21 06:27:41 EST 2006


On 21/02/2006, at 10:14 PM, Gavin wrote:
>> All I can suggest then is to modify lib/python/mod_python/ 
>> Session.py in
>> mod_python source code and add in some debug statements to see what
>> session database name is being set to.
>>
>> class DbmSession(BaseSession):
>>
>>     def __init__(self, req, dbm=None, sid=0, secret=None,
>> dbmtype=anydbm,
>>                  timeout=0, lock=1):
>>
>>         if not dbm:
>>             opts = req.get_options()
>>             if opts.has_key("session_dbm"):
>>                 dbm = opts["session_dbm"]
>>             else:
>>                 dbm = os.path.join(opts.get('session_directory',
>> tempdir), 'mp_sess.dbm')
>>
>>         self._dbmfile = dbm
>>         self._dbmtype = dbmtype
>>
>>         # XXX DEBUG
>>
>>         apache.log_error("dbmfile=%s"%self._dbmfile)
>>
>> Reinstall mod_python and restart Apache.
>>
>> Then when running test, look in Apache error_log to see where it
>> thinks it is getting
>> put. See if file exists if not in /tmp.
>>
> mp_sess_test.dbm file doesn't exists in /tmp. error_log file are as  
> following:

Run an interactive Python session and try:

grumpy:~ grahamd$ python
Python 2.3.5 (#1, Mar 20 2005, 20:38:20)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import anydbm
 >>> db = anydbm.open("/tmp/mp_sess_test.dbm",'c')
 >>>

If that works, try the same thing in a really simple mod_python handler
independent of Session class. Ie.,

from mod_python import apache
import anydbm

def handler(req):
     req.content_type = 'text/plain'
     db = anydbm.open("/tmp/mp_sess_test.dbm",'c')
     db.close()
     req.write('test ok')
     return apache.OK

If it works outside of mod_python and not in mod_python, may be some
problem to do with a mixing of wrong versions of shared libraries.

If it doesn't work outside of mod_python either, make sure permissions
on "/tmp" directory look correct, or try creating it in a different  
directory
that you own.

Time for me to sleep. Will see how you go in the morning.

Graham


More information about the Mod_python mailing list