在继承了遗留的谷歌应用引擎应用程序后,我刚刚从 PHP 转向 Python。我尝试按照各种在线教程迁移到 python 2.7,但由于以下错误,我无法理解。这与我调用 GAE 或 Django api 的方式有关吗?
...
runtime: python27
api_version: 1
threadsafe: yes
builtins:
- remote_api: on
inbound_services:
- warmup
libraries:
- name: django
version: "1.2"
...
我还有
from google.appengine.ext.webapp.util import run_wsgi_app
在我的代码中,是否应该将其更改为 builin?
ERROR 2012-02-28 16:31:00,167 wsgi.py:205]
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine- default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 193, in Handle
result = handler(self._environ, self._StartResponse)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django_1_2/django/core/handlers/wsgi.py", line 248, in __call__
response = self.get_response(request)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django_1_2/django/core/handlers/base.py", line 141, in get_response
return self.handle_uncaught_exception(request, resolver, sys.exc_info())
UnboundLocalError: local variable 'resolver' referenced before assignment
INFO 2012-02-28 16:31:00,178 dev_appserver.py:2884] "GET /ibi/index.html HTTP/1.1" 500 -
最佳答案
不要在 Python 2.7 运行时中使用 run_wsgi_app
。在您的 app.yaml
中,您必须引用实际的 WSGI 应用程序对象。
参见documentation here关于如何正确配置 Django
关于python - 将 GAE 应用程序迁移到 Python 2.7 后出现 wsgi.py 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9486431/