Of course this approach is only valid if I can guarantee no subsequent put() operations will happen in a single request which in my case unlikely. Or is there a better generic approach you can suggest?
On Mon, Mar 8, 2010 at 4:09 PM, Sümer Cip <[email protected]> wrote: > Yes, exactly, I finally found the problem yesterday, gaeutlities session > behaves different on each object. So how about this solution: I have a base > handler class for all the handlers and what I added is to refresh the user > param from the datastore for every __init__ function. How that sounds? > > class scRequestHandler(webapp.RequestHandler): > def __init__(self): > webapp.RequestHandler.__init__(self) > self.Session = scSession() > # reload the user object, this is because the refeernce property in > the Session > # object is somehow pickled and the put() operation does not update > the real entity. > # even though they have the same keys(). > # The solution is to get the user from DS for every request. > if self.Session.user: > self.Session.user = db.get(self.Session.user.key()) > > > On Mon, Mar 8, 2010 at 2:55 PM, Nick Johnson (Google) < > [email protected]> wrote: > >> Hi Sumer, >> >> You're storing an entity in the session, and unless the gaeutilities >> session object handles this specially, this results in it pickling the >> 'user' entity and storing it in the session. Calling .put() on the user >> object will update the datastore with the new value, but won't change the >> pickled value the session object is storing. Next request, it will >> deserialize the same data it did previously, with no update. >> >> -Nick Johnson >> >> >> On Sat, Mar 6, 2010 at 2:22 PM, Sumer Cip <[email protected]> wrote: >> >>> Hi all, >>> >>> Below is the code code I am using in my tests to update a reference >>> tied to my session, the session object I use if from gaeutilities >>> (wrapped it a little). I put a reference object in the session and all >>> working fine. >>> >>> if not self.Session.user: >>> user = scMember.all().filter("name = ", >>> "testmember").get() >>> self.Session.user = user >>> else: >>> self.Session.user.playcount += 1 >>> self.Session.user.put() >>> >>> The problem with this code is the put() is not working, if I do not >>> restart app engine SDK. In the error scenario, user is set into the >>> session object, and in the second request I can update the playcount >>> only once. BUt the subsequent operations fail without any notice of >>> error and playcount stays "1" everytime even I have incremented it. >>> This is the testhandler and there is no other code running paralelly. >>> When I restart the SDK, the problem goes away, it works fine. >>> So, I am not sure if I am doing something wrong, it took me 6 hours to >>> identify this thing. >>> >>> Any help will be appericiated. >>> >>> Thanks, >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Google App Engine" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]<google-appengine%[email protected]> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/google-appengine?hl=en. >>> >>> >> >> >> -- >> Nick Johnson, Developer Programs Engineer, App Engine >> Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: >> 368047 >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google App Engine" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<google-appengine%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/google-appengine?hl=en. >> > > > > -- > Sumer Cip > -- Sumer Cip -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
