[mod_python] Multiple call to Session.Session(req) problem

Alex Greif alex.greif at gmail.com
Fri Oct 13 15:43:54 EDT 2006


yep your hint solved the problem.

BTW it would be helpful to mention this issue in the PDF document.

Alex.

On 10/13/06, Jim Gallacher <jpg at jgassociates.ca> wrote:
> Alex Greif wrote:
> > Hi,
> >
> > I have the problem that getting the session instance in a handler more
> > than once makes the server hang on the second access to the session.
> > the problem does ot occure on windows XP but on suse Linux with 3.2.10
> >
> > Here is my scenario:
> >
> > def view_ticket_detail(req, ticketId):
> >    def __access__(req, user):
> >        ...
> >        # webutil.authorize will get the session
> >        return webutil.authorize(req=req, login=user, neededRole=neededRole)
> >
> >    req.content_type = "text/html"
> >    ...
> >    # now I need the session again
> >    session = Session.MemorySession(req) ###### <-- here the server hangs
> >
> > any ideas?
>
> Yep. You've deadlock the session. You can't have more than one session
> instance in the same request.
>
> Put your session in the req object within your webutil.authroize() code,
> and when you need it later retrieve it from there.
>
> webutil.py
> ==========
>
> def authorize(req):
>      req.session = Session.MemorySession(req)
>      ...
>
> And in when you need it later:
>
> def view_ticket_detail(req, ticketId):
>     def __access__(req, user):
>         ...
>         # webutil.authorize will get the session
>         return webutil.authorize(req=req, login=user, neededRole=neededRole)
>
>     req.content_type = "text/html"
>     ...
>     # now I need the session again
>     session = req.session
>
>
> Jim
>


More information about the Mod_python mailing list