开发者

Getting Beaker working with GAE

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开发者_C百科:

  • 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.


SessionMiddleware is in middleware.py. Try:

from beaker.middleware import SessionMiddleware


I answered my question by re-approaching the problem with webapp and Google's Users service which has better documentation for working with GAE.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜