[mod_python] Using session management?

Steve Bergman steve at rueb.com
Thu Sep 15 20:22:49 EDT 2005


Is there good documentation somewhere on using the Session module, 
preferably with examples?  From the mod_python manual, I've gotten this far:

---
from mod_python import Session

def main(req):
    sess = Session.Session(req)
    pprint.pprint(sess)
    if sess.is_new():
        s = '<html>This is a new session.</html>'
        sess.myVar2 = "I am a session variable."
        sess.save()
        return s
    else:
        s='<html>This is an old session.  myVar2 = ' + sess.myVar2 + 
'</html>'
        sess.load()
        s+= sess.myVar2
        sess.save()
        return s
---

This works in that the first time, I get "This is a new session" and it 
does not complain about setting sess.myVar2.

But on the second load, it complains that dbmSesion does not have an 
attribute myVar2.

When you save the session, what all gets saved?

Thanks,
Steve Bergman


More information about the Mod_python mailing list