Rested
Rested

Reputation: 197

Enabling Beaker SessionMiddleware through Bottle on Google App Engine

I am trying to use beaker for session handling in my bottle based GAE app. The problem is that I need to run "app" here as the app

session_opts = {
    'session.type': 'ext:google',
    'session.auto': True,
}

app = beaker.middleware.SessionMiddleware(bottle.app(), session_opts)

then call

bottle.run(app=app)

but I can't because as it says in the example bottle app:

# Note: We don't need to call run() since our application is embedded within
# the App Engine WSGI application server.

So my question is how can I run the server with the beaker session middleware?

Upvotes: 1

Views: 517

Answers (1)

Rested
Rested

Reputation: 197

Okay I have found the cause of the problem - thanks for getting me to think Gianni. Basically I had

- url: .*
  script: main.bottle

which means that GAE treats the bottle variable in my main.py as the "app". So when I did this instead:

from bottle import app, route, hook...

session_opts = {
    'session.type': 'ext:google',
    'session.auto': True,
}

bottle = beaker.middleware.SessionMiddleware(app(), session_opts)

It all worked a treat. Guess that'll teach me for not reading the app engine docs enough.

Upvotes: 1

Related Questions