views:

56

answers:

2

GAE webapp allows to map single handler to a route:

application = webapp.WSGIApplication([
                                     ('/login', gae_handlers.UserLogin),
                                     ], debug=True)

Is there any way I can have a chain of request handlers?

I want to have handler which does authentication before all other handlers run.

+5  A: 

You can do this either with decorators or with WSGI middleware.

There's a good example of using a decorator in this answer. Nick Johnson's AEoid project uses the middleware approach.

Wooble
A: 

I have found another way

class ExtendedRequest(google.appengine.ext.webapp.WSGIApplication.REQUEST_CLASS):
    # I can basically do anything here
    def get_session_id(self):
        return self.cookies.get('session_id')

google.appengine.ext.webapp.WSGIApplication.REQUEST_CLASS = ExtendedRequest
Konstantin Spirin