Sessions error

22 views
Skip to first unread message

ajgomezlopez

unread,
Apr 17, 2011, 3:34:11 PM4/17/11
to appengine-utilities
Hello, Im using gaeutils sessions for an aplication in appengine. I
use my own model as this way:

*****
from gaeutils import sessions
from google.appengine.ext.webapp import RequestHandler

class RequestHandlerExt(RequestHandler):

def __init__(self):
RequestHandler.__init__(self)
self.SESSION = sessions.Session()
if not 'times' in self.SESSION:
self.SESSION['times'] = 0
if not 'login' in self.SESSION:
self.SESSION['login'] = ''
if not 'email' in self.SESSION:
self.SESSION['email'] = ''
if not 'lang' in self.SESSION:
self.SESSION['lang'] = 'es'
if not 'activecustomer' in self.SESSION:
self.SESSION['activecustomer'] = ''
******

So i can chek my session vars in all of my RequestHandlerExt
instances.

But wen pass some time, if i go to login in my application throw an
Internal server error .
I have this information from the log.

******
<class 'google.appengine.api.datastore_errors.BadKeyError'>: Invalid
string key
ahNhamdvbWV6bG9wZXotc2FtcGxlciMLEhtfQXBwRW5naW5lVXRpbGl0aWVzX1Nlc3Npb24Y.
Traceback (most recent call last):
File "/base/data/home/apps/ajgomezlopez-sample/2.349694386919970151/
main.py", line 147, in main
util.run_wsgi_app(application)
File "/base/python_runtime/python_lib/versions/1/google/appengine/
ext/webapp/util.py", line 98, in run_wsgi_app
run_bare_wsgi_app(add_wsgi_middleware(application))
File "/base/python_runtime/python_lib/versions/1/google/appengine/
ext/webapp/util.py", line 116, in run_bare_wsgi_app
result = application(env, _start_response)
File "/base/python_runtime/python_lib/versions/1/google/appengine/
ext/webapp/__init__.py", line 619, in __call__
handler = handler_class()
File "/base/data/home/apps/ajgomezlopez-sample/2.349694386919970151/
webappext.py", line 10, in __init__
self.SESSION = sessions.Session()
File "/base/data/home/apps/ajgomezlopez-sample/2.349694386919970151/
gaeutils/sessions.py", line 562, in __init__
self.session = _AppEngineUtilities_Session.get_session(self)
File "/base/data/home/apps/ajgomezlopez-sample/2.349694386919970151/
gaeutils/sessions.py", line 142, in get_session
ds_session = db.get(str(session_key))
File "/base/python_runtime/python_lib/versions/1/google/appengine/
ext/db/__init__.py", line 1422, in get
keys, multiple = datastore.NormalizeAndTypeCheckKeys(keys)
File "/base/python_runtime/python_lib/versions/1/google/appengine/
api/datastore.py", line 180, in NormalizeAndTypeCheckKeys
keys = [_GetCompleteKeyOrError(key) for key in keys]
File "/base/python_runtime/python_lib/versions/1/google/appengine/
api/datastore.py", line 2339, in _GetCompleteKeyOrError
key = Key(arg)
File "/base/python_runtime/python_lib/versions/1/google/appengine/
api/datastore_types.py", line 364, in __init__
raise datastore_errors.BadKeyError('Invalid string key %s.' %
encoded)
******

1º.- ¿Any one knows why is happend this?

2º.- ¿Is there any way to add a variable to a session without
declarate first?

Thanks for all in advance and sorry for my english.

Joe Bowman

unread,
Apr 19, 2011, 12:46:41 PM4/19/11
to appengine...@googlegroups.com
This has been popping up for a few people. Not sure why, as the key is generated from the datastore in the first place. Unfortunately I'm not using appengine anymore so haven't had time to try and reproduce and solve the issue.

Shehabic

unread,
Apr 23, 2011, 12:09:06 PM4/23/11
to appengine-utilities
I have the same issue . . please let me know if anyone have a
solution . .

Ed Estes

unread,
Aug 18, 2011, 11:48:58 AM8/18/11
to appengine...@googlegroups.com
Any updates here?  I just started getting this error yesterday as reported here.

--Ed

Joe Bowman

unread,
Aug 18, 2011, 11:55:57 AM8/18/11
to appengine...@googlegroups.com
I haven't heard anything from Google about this. 

Joe Bowman

unread,
Aug 18, 2011, 12:01:49 PM8/18/11
to appengine...@googlegroups.com
Honestly, my suggestion at this point would be to dive into the rewrite I've considered doing for a while, and writing a new handler for the ids, probably a uuid or something similar. 

However, I'm not using appengine any more so don't have the time currently to invest in the rewrite. The basic gist is in this ticket


The ideas are basically to overhaul sessions for performance and to move the entire process to a decorator which would be more efficient. I've updated that ticket with information on switching to uuid for unique identifiers.
Reply all
Reply to author
Forward
0 new messages