GAESessions(Python) - “AttributeError: 'thread._local'对象没有'current_session'属性。”
我最近在尝试把Janrain Engage这个插件加到我正在开发的应用里(使用的是Google App Engine(Python 2.7)),并且用GAESessions作为会话管理库。
按照GAESessions页面上的说明,我在应用的根目录下创建了一个“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'
我查阅了关于“get_current_session()”问题的其他帖子和相关帖子,但它们似乎提到的是'local'而不是'thread._local'。
有没有人知道这是怎么回事?提前谢谢大家!
========
{根文件夹}/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 个回答
1
{根文件夹}/appengine_config.py 是不是在根目录下的 appengine_config.py 文件?
aaps/app.yaml
/main.py
/appengine_config.py
/gaesessions #folder
可以查看一个关于 gaesessions 的基础教程