[mod_python] Session Freezing using mod_python.Session

Graham Dumpleton graham.dumpleton at gmail.com
Wed Mar 14 18:04:52 EST 2007

On 15/03/07, Kenneth Loafman <kenneth at loafman.com> wrote:
> Graham Dumpleton wrote:
> > On 15/03/07, Kenneth Loafman <kenneth at loafman.com> wrote:
> >> Hi,
> >>
> >> The small snippet of code below freezes if there is an existing pysid
> >> cookie (sample straight out of the manual).  If there is no pysid
> >> cookie, then index() displays, but show() hangs.
> >
> > Yet you don't show us the code in show() which is the important bit.
> It turns out that I did show the important bit, a blind request to get a
> new session.
> > Normal practice is to always use:
> >
> >     if not hasattr(req,'session'):
> >       req.session = Session.Session(req)
> >
> >     if req.session.is_new():
> >       ...
> This is exactly what I needed.  index() got the session, then called
> show() which tried to get a new session.  The docs seem to imply that
> Session(req) should look to see if a session exists, then use it.
> Obviously, that implication is not valid.

Hmmm, the code example you posted does not show index() calling
show(). That the form had it as the target of the action doesn't
result in index() calling show() within the code.

What the docs is referring to is that the Session object will look in
the session database to see if an existing persistent session entry is
there from a previous request, not that it will look to see if a prior
Session object instance has been created for the current request.


More information about the Mod_python mailing list