Google app engine 如何使用webapp.RequestHandler链处理请求

Google app engine 如何使用webapp.RequestHandler链处理请求,google-app-engine,authentication,web-applications,Google App Engine,Authentication,Web Applications,GAE webapp允许将单个处理程序映射到路由: application = webapp.WSGIApplication([ ('/login', gae_handlers.UserLogin), ], debug=True) 有没有办法让我拥有一个请求处理程序链 我想让处理程序在所有其他处理程序运行之前进行身份验证。您可以使用装饰程序或WSG

GAE webapp允许将单个处理程序映射到路由:

application = webapp.WSGIApplication([
                                     ('/login', gae_handlers.UserLogin),
                                     ], debug=True)
有没有办法让我拥有一个请求处理程序链


我想让处理程序在所有其他处理程序运行之前进行身份验证。

您可以使用装饰程序或WSGI中间件来实现这一点


这里有一个很好的例子,可以在中使用decorator。Nick Johnson的项目使用中间件方法。

我找到了另一种方法

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