我是Python(以及GAE)的新手,我正在尝试将gaesessions包含在我的应用程序中,这正是我所做的:
我将gaesessions文件夹复制到我的src文件夹(该文件夹包含__init__.py
文件)
并将其添加到我的工作代码中:
from gaesessions import get_current_session
session = get_current_session()
我收到以下错误:
Traceback (most recent call last): File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 174, in Handle result = handler(self._environ, self._StartResponse)
File "C:\Program Files\Google\google_appengine\lib\webapp2\webapp2.py", line 1519, in __call__ response = self._internal_error(e)
File "C:\Program Files\Google\google_appengine\lib\webapp2\webapp2.py", line 1511, in __call__ rv = self.handle_exception(request, response, e)
File "C:\Program Files\Google\google_appengine\lib\webapp2\webapp2.py", line 1505, in __call__ rv = self.router.dispatch(request, response)
File "C:\Program Files\Google\google_appengine\lib\webapp2\webapp2.py", line 1253, in default_dispatcher return route.handler_adapter(request, response)
File "C:\Program Files\Google\google_appengine\lib\webapp2\webapp2.py", line 1077, in __call__ return handler.dispatch()
File "C:\Program Files\Google\google_appengine\lib\webapp2\webapp2.py", line 547, in dispatch return self.handle_exception(e, self.app.debug)
File "C:\Program Files\Google\google_appengine\lib\webapp2\webapp2.py", line 545, in dispatch return method(*args, **kwargs)
File "D:....\src\helloworld.py", line 13, in get session = get_current_session()
File "D:....\src\gaesessions\__init__.py", line 36, in get_current_session return _tls.current_session
File "C:\Python27\lib\_threading_local.py", line 193, in __getattribute__ return object.__getattribute__(self, name)
答案 0 :(得分:7)
你已经从堆栈跟踪中省略了实际的异常,但我猜是这样的:
AttributeError:'local'对象没有属性'current_session'
如果是这样,您很可能会跳过middleware configuration步骤。根据说明创建appengine_config.py
并重新启动开发服务器;这应该可以解决你的错误。