python webapp2框架,def func_名称(处理程序):
处理程序类用于以下目的: 例如:python webapp2框架,def func_名称(处理程序):,python,google-apps-script,webapp2,Python,Google Apps Script,Webapp2,处理程序类用于以下目的: 例如: def user_required(handler): """ Decorator that checks if there's a user associated with the current session. Will also fail if there's no session present. """ def check_login(self, *args, **kwargs): auth = self.auth
def user_required(handler):
"""
Decorator that checks if there's a user associated with the current session.
Will also fail if there's no session present.
"""
def check_login(self, *args, **kwargs):
auth = self.auth
if not auth.get_user_by_session():
self.redirect(self.uri_for('login'), abort=True)
else:
return handler(self, *args, **kwargs)
return check_login
实际上是这样的:您提到的示例用作。处理程序是传递给要装饰的装饰器的方法。此装饰器是
类AuthenticatedHandler(BaseHandler):
中的后续用户
大体上,在您的示例中,get
方法由user\u required
修饰,因此要了解发生了什么,只需将处理程序
替换为get