让 Beaker 与 GAE 一起工作
我正在尝试将我在本地运行的应用程序移植到 GAE。该应用程序使用 Bottle.py 框架。我使用 Beaker 进行会话管理。我有点菜鸟,无法正确导入烧杯。非常感谢帮助。
我正在 Mac OS X 10.6.7 下使用 GoogleAppEngineLauncher.app 运行移植的应用程序。这会在我的机器上的模拟环境中运行该应用程序,而不是在 Google 的服务器上。
对于我的 GAE 移植,我将 Bottle.py 放入名为“framework”的目录中。该目录有一个空的 __init__.py
文件。 Bottle 工作正常,可以提供“hello world”服务。
Beaker 存在于我的应用程序根目录中自己的目录中(journal/beaker)。烧杯还有一个空的__init__.py
。
相关代码:
from framework import bottle
from beaker import SessionMiddleware
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
@bottle.route('/')
def index():
return "hello, world"
def main():
bottle.debug(True)
run_wsgi_app(bottle.default_app())
if __name__ == '__main__':
main()
我收到如下错误消息:
File "/Users/mscantland/code/journal/main.py", line 19, in <module>
from beaker import SessionMiddleware
ImportError: cannot import name SessionMiddleware
这是迄今为止我尝试实现的操作:
检查了 /beaker 中所有内容的权限以确保它们可执行。
按原样运行烧杯并重写所有导入语句,以便:
from beaker.x import y
变为:
from x import y
- 添加了标准库中不存在的“pkg_resources.py”用于 GAE 使用的 Python 版本。
I'm trying to port an app I've been running locally to GAE. The app uses the Bottle.py framework. I use Beaker for session management. I'm a bit of a noob and am having trouble getting Beaker imported properly. Help greatly appreciated.
I'm running the ported app using GoogleAppEngineLauncher.app under Mac OS X 10.6.7. This runs the app in the simulation environment on my machine, not on Google's servers.
For my GAE port, I've put Bottle.py into a directory called 'framework'. This directory has an empty __init__.py
file. Bottle is working fine and can serve 'hello world'.
Beaker exists in its own directory in the root of my app (journal/beaker). Beaker also has an empty __init__.py
.
Relevant code:
from framework import bottle
from beaker import SessionMiddleware
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
@bottle.route('/')
def index():
return "hello, world"
def main():
bottle.debug(True)
run_wsgi_app(bottle.default_app())
if __name__ == '__main__':
main()
I get an error message like this:
File "/Users/mscantland/code/journal/main.py", line 19, in <module>
from beaker import SessionMiddleware
ImportError: cannot import name SessionMiddleware
Here is what I have tried to get this working so far:
Checked permissions on everything in /beaker to make sure they were executable.
Ran beaker as-is and also re-wrote all import statements so that:
from beaker.x import y
became:
from x import y
- Added 'pkg_resources.py' which is not in the standard library for the Python version GAE uses.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SessionMiddleware 位于 middleware.py 中。尝试:
SessionMiddleware is in middleware.py. Try:
我通过重新处理 webapp 和 Google 用户服务的问题来回答我的问题,该服务具有更好的与 GAE 配合使用的文档。
I answered my question by re-approaching the problem with webapp and Google's Users service which has better documentation for working with GAE.