[mod_python] Session hanging

Shawn Harrison harrison at tbc.net
Wed Feb 23 23:47:34 EST 2005


Very strange Session problem. On Debian Linux 2.4.25, Python 2.3.3, 
mod_python ??? ("__init__.py,v 1.10 2004/02/16")

I've been using session variables to keep a list of the current users' 
allowed groups. On the login POST script:

         session = Session.Session(req)

         # Set the username and groups that this user belongs to
         grouplist = []
         groups = db.select('groups_memberships_users', 'groupname', 
"username = '%s'" % user.name)
         for i in range(len(groups)):
             grouplist.append(groups[i].groupname)
         session['groups'] = "|".join(grouplist)

The result is, for instance, session['groups'] = 'editor|verified|admin' 
(for me).

This has been working just fine. However, today when I called the 
following code it hangs, every time:

def edit_group(req):
     from mod_python import Session
     sess = Session.Session(req) # <-- Hangs here
     sess.load()

This is exactly what I have been doing all the time in my authen 
handler; this is outside of the authen handler in order to get the list 
of groups and the current user's name (I'm not using Apache 
authentication at all but am using Session for all of it).

Thereafter, any attempt to load a page which needs to access the Session 
  object hangs. That is, anything which is non-public and therefore goes 
through authen checking.

I suppose I could work around this by setting the req table with 
appropriate data during authen, which would make the user & group info 
always available. Probably would be more efficient, too. But it begs the 
question: Is there some reason that this would be happening with Session?

Note: The same code works just fine on Windows 2000 w/Apache 2.0.52, but 
in that case of course it's a MemorySession rather than a DbmSession. So 
I'm guessing that the difference has to do with the DBM session object 
or underlying file.

Thanks,
Shawn Harrison


More information about the Mod_python mailing list