GAESessions(Python) - “AttributeError:'thread._local'对象没有属性'current_session'。”

时间:2013-03-24 23:32:14

标签: python google-app-engine python-2.7

所以我一直在尝试使用GAESessions作为会话库,将Janrain Engage插件实现到我正在使用的应用程序(Google App Engine(Python 2.7))。

按照GAESessions page上的说明,我在应用程序的根目录中创建了“gaesessions”文件夹(包含“__init__.py”)以及“appengine_config.py”,以及相关文件处理插件。

然而,尝试通过Janrain登录时,给我一个500错误并在GAE日志中给了我这个回溯:

E 2013-03-25 07:06:55.535

'thread._local' object has no attribute 'current_session'
Traceback (most recent call last):
  File "/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 "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.1/webapp2.py", line 1530, in __call__
    rv = self.router.dispatch(request, response)
  File "/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 "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.1/webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "/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 "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.1/webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~k-sketch-test/10.366190612177083948/rpx.py", line 56, in post
    session = get_current_session()
  File "/base/data/home/apps/s~k-sketch-test/10.366190612177083948/gaesessions/__init__.py", line 38, in get_current_session
    return _tls.current_session
AttributeError: 'thread._local' object has no attribute 'current_session'

我搜索了other posts关于“get_current_session()”的问题,但它们似乎引用了'local'而不是'thread._local'。

关于这里发生了什么的任何想法?提前谢谢!

======

{root folder} /appengine_config.py

from gaesessions import SessionMiddleware

import os
COOKIE_KEY = '<hidden - was generated through os.urandom(64)>'

def webapp_add_wsgi_middleware(app):
  from google.appengine.ext.appstats import recording
  app = SessionMiddleware(app, cookie_key=COOKIE_KEY)
  app = recording.appstats_wsgi_middleware(app)
  return app

======

1 个答案:

答案 0 :(得分:1)

{root folder} /appengine_config.py 根文位置中的文件是appengine_config.py吗?

aaps/app.yaml
    /main.py
    /appengine_config.py
    /gaesessions #folder

可以查看basic tutorial on gaesessions