[mod_python] Sessions

Graham Dumpleton grahamd at dscpl.com.au
Thu Jun 2 20:20:56 EDT 2005

Joshua Ginsberg wrote ..
> So for example:
> <%
> # sessionfu.psp
> from mod_python import Session
> import pprint
> pp = pprint.PrettyPrinter()
> sess = Session.Session(req)
> newkey = form.getfirst('newkey','')
> newvalue = form.getfirst('newvalue','')
> %>

For mod_python.psp, you are actually doing more work here than you
strictly need to and why I asked original poster if they were intending
to use add ons like mod_python.psp.

When using mod_python.psp, the mere act of accessing a variable
called "session" will result in the creation by mod_python.psp itself
of a Session object for you. The underlying mod_python.psp code will
also save the session object for you once your page is done.

You may have had a problem with your example code because it didn't
appear to do a save of the session. Other than that it may well have
worked, but you could have avoided creating the session object in the
first place.

Hope this helps.


More information about the Mod_python mailing list