Gregory (Grisha) Trubetskoy wrote:

On Mon, 13 Mar 2006, Jim Gallacher wrote:

The idea of something like req.get_session() is to give users an obvious way to grab a session object without the deadlock concerns. How many times have we seen this kind of problem-code on the mailing list?

def index(req):
   sess = Session.Session(req)

def do_stuff(req):
   sess = Session.Session(req)
   ... do other stuff.

Having the session constructor check for the existence of req.session is of no use here. We need a way to make sure only *one* session instance is created per request. (Bonus marks for making it work with internal redirect).

[sorry, i only read the beginning of the message, so i might be not fully understanding]

Session.Session is not a constructor, just a function. But also, if it were, I think this can be solved with the new object's __new__() ?

You're right, I misspoke. It is a function, but it does return a new session instance so there is a constructor in there somewhere. ;)


Reply via email to