python - Strange error: AssertionError: Request global variable is not set -
im getting frustrated error. after updated sdk 1.6.6 im starting see following error first time run handlers.
assertionerror: request global variable not set.
the important part of stacktrace
request global variable not set. traceback (most recent call last): file "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.1/webapp2.py", line 1536, in __call__ rv = self.handle_exception(request, response, e) file "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.1/webapp2.py", line 1530, in __call__ rv = self.router.dispatch(request, response) file "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.1/webapp2.py", line 1278, in default_dispatcher return route.handler_adapter(request, response) file "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.1/webapp2.py", line 1102, in __call__ return handler.dispatch() file "/base/data/home/apps/s~kobstadendev/1.359392875892326983/main.py", line 81, in dispatch webapp2.requesthandler.dispatch(self) file "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.1/webapp2.py", line 572, in dispatch return self.handle_exception(e, self.app.debug) file "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.1/webapp2.py", line 570, in dispatch return method(*args, **kwargs) file "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1009, in synctasklet_wrapper return taskletfunc(*args, **kwds).get_result() file "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 322, in get_result self.check_success() file "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 362, in _help_tasklet_along value = gen.send(val) file "/base/data/home/apps/s~kobstadendev/1.359392875892326983/items_ndb/items.py", line 439, in user = self.auth.get_user_by_session() file "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.1/webapp2.py", line 726, in __get__ value = self.func(obj) file "/base/data/home/apps/s~kobstadendev/1.359392875892326983/main.py", line 88, in auth return auth.get_auth() file "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.1/webapp2_extras/auth.py", line 623, in get_auth request = request or webapp2.get_request() file "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.1/webapp2.py", line 1720, in get_request assert getattr(_local, 'request', none) not none, _get_request_error assertionerror: request global variable not set. it seems isnt going right when loading new instance. when handler gets loaded , try use
user = self.auth.get_user_by_session()
webapp2 isnt loaded properly, because if refresh , hit same instance error goes away. has seen error, or direction apreciated.
edit:
a little more info. im using
libraries: - name: webapp2 version: latest and python 2.7 . basehandler looks this
class basehandler(webapp2.requesthandler): """ basehandler requests holds auth , session properties reachable requests """ def dispatch(self): # session store request. self.session_store = sessions.get_store(request=self.request) try: # dispatch request. webapp2.requesthandler.dispatch(self) finally: # save sessions. self.session_store.save_sessions(self.response) @webapp2.cached_property def auth(self): return auth.get_auth() @webapp2.cached_property def session(self): # returns session using default cookie key. return self.session_store.get_session() @webapp2.cached_property def session_store(self): return sessions.get_store(request=self.request) @webapp2.cached_property def messages(self): return self.session.get_flashes(key='_messages') def add_message(self, message, level=none): self.session.add_flash(message, level, key='_messages') @webapp2.cached_property def user(self): return self.auth.get_user_by_session() app = ndb.toplevel(webapp2.wsgiapplication(routes.urls, debug=config.debug, config=config.config)) something wrong webapp2 ?
this seems bug in webapp2 library discussed here: https://groups.google.com/forum/?fromgroups=#!topic/webapp2/shb2ryxgdlc
Comments
Post a Comment