python webapp2框架,def func_name(处理程序):

时间:2014-03-07 12:31:05

标签: 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
    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

1 个答案:

答案 0 :(得分:0)

您提及的示例用作decorator。 Handler是一种传递给要装饰的装饰器的方法。此装饰器稍后是class AuthenticatedHandler(BaseHandler):中的用户。

粗略地说,在您的示例中,get方法由user_required修饰,因此要了解正在进行的操作,只需将handler替换为get

相关问题