Example on how to delete a cookie when application is restarted.

0 views
Skip to first unread message

sr

unread,
Feb 20, 2009, 8:15:38 AM2/20/09
to appengine-utilities
Is there an example of how to delete a cookie on restarting the
application.
I seem to hitting this error every time I restart the session -
deleting the cookie resolves the issue.
Just not sure how to trap for this in the application and would
appreciate a quick example.

thanks,
-sr

ERROR 2009-02-20 13:01:00,732 __init__.py] Traceback (most recent
call last):
File "c:\dev\Google\google_appengine\google\appengine\ext\webapp
\__init__.py", line 496, in __call__
handler.get(*groups)
File "c:\dev\Google\gaeutils\main.py", line 57, in get
self.sess = sessions.Session()
File "c:\dev\Google\gaeutils\appengine_utilities\sessions.py", line
249, in __init__
self.sid = self.new_sid()
File "c:\dev\Google\gaeutils\appengine_utilities\sessions.py", line
310, in new_sid
sid = str(self.session.key()) + md5.new(repr(time.time()) + \
AttributeError: 'NoneType' object has no attribute 'key'

Joe Bowman

unread,
Feb 20, 2009, 9:48:45 AM2/20/09
to appengine-utilities
It's actually a bug introduced in version 1.1.3 that wasn't caught.
Deleting the cookie isn't necessary. The fix that I believe will work
(should get a chance to verify the fix tonight) is below. Issue 16 -
http://code.google.com/p/gaeutilities/issues/detail?id=16 is where
this can be tracked.

The fix will be: (sorry writing this by hand, no opportunity to do a
diff)
At line 172 in sessions.py:

# start a new session
+ self.session = _AppEngineUtilities_Session()
+ self.session.put()
self.sid = self.new_sid()

shishir ramam

unread,
Feb 20, 2009, 10:38:51 AM2/20/09
to Joe Bowman, appengine-utilities

Thanks much. I am on trunk and the diff that worked (line numbers were different) . ..

+++ lib\gaeutils\sessions.py Fri Feb 20 07:11:52 2009
@@ -247,6 +246,7 @@
  if new_session:


  # start a new session

- self.sid = self.new_sid()


  self.session = _AppEngineUtilities_Session()
+ self.session.put()

+ self.sid = self.new_sid()
  if 'HTTP_USER_AGENT' in os.environ:
  self.session.ua = os.environ['HTTP_USER_AGENT']


Joe Bowman

unread,
Feb 20, 2009, 10:58:33 AM2/20/09
to appengine-utilities
Ah ok, yea, the trunk has major modifications from version 1.1.3, with
the new cookie only session functionality.

If you're using the trunk, please be aware there are still as of yet
undocumented features because of this. If you're using only session,
and not the django middleware, then there is no problem as the
standard datastore backed sessions are in play.

I'll be working on documentation of the new features this evening,
which is what may delay the new 1.2 release.

On Feb 20, 10:38 am, shishir ramam <srg...@gmail.com> wrote:
> Thanks much. I am on trunk and the diff that worked (line numbers were
> different) . ..
>
> +++ lib\gaeutils\sessions.py Fri Feb 20 07:11:52 2009
> @@ -247,6 +246,7 @@
>   if new_session:
>   # start a new session
> - self.sid = self.new_sid()
>   self.session = _AppEngineUtilities_Session()
> + self.session.put()
> + self.sid = self.new_sid()
>   if 'HTTP_USER_AGENT' in os.environ:
>   self.session.ua = os.environ['HTTP_USER_AGENT']
>
> On Fri, Feb 20, 2009 at 6:48 AM, Joe Bowman <bowman.jos...@gmail.com> wrote:
>
> > It's actually a bug introduced in version 1.1.3 that wasn't caught.
> > Deleting the cookie isn't necessary. The fix that I believe will work
> > (should get a chance to verify the fix tonight) is below. Issue 16 -
> >http://code.google.com/p/gaeutilities/issues/detail?id=16is where
Reply all
Reply to author
Forward
0 new messages