views:

72

answers:

1
@required_admin
def get(self):

i want to use this method to make user must be admin.

thanks

+2  A: 

The standard route is to use login: admin in your app.yaml, but here's a decorator:

def admin_required(handler_method):
  def check_admin(self, *args):
    if not users.is_current_user_admin():
      self.redirect(users.create_login_url(self.request.uri))
      return
    else:
      handler_method(self, *args)
  return check_admin
Drew Sears