For which purpose handler class used:
example:
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
actually it is from this tutorial :
Example you mention is used as decorator. Handler is a method passed to a decorator to be decorated. This decorator is later user in class AuthenticatedHandler(BaseHandler):
.
Roughly, in your example, get
method is decorated by user_required
, thus to understand what's going on just replace handler
with get