使用的处理程序类:
示例:
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
实际上是来自tutorial:
答案 0 :(得分:0)
您提及的示例用作decorator。 Handler是一种传递给要装饰的装饰器的方法。此装饰器稍后是class AuthenticatedHandler(BaseHandler):
中的用户。
粗略地说,在您的示例中,get
方法由user_required
修饰,因此要了解正在进行的操作,只需将handler
替换为get