#NEWLINE# def admin_required( handler_method ) : #NEWLINE# #INDENT# "A decorator to require that a user be an admin for this application\n    to access a handler.\n\n    To use it, decorate your get() method like this::\n\n        @admin_required\n        def get(self):\n            user = users.get_current_user(self)\n            self.response.out.write('Hello, ' + user.nickname())\n\n    We will redirect to a login page if the user is not logged in. We always\n    redirect to the request URI, and Google Accounts only redirects back as\n    a GET request, so this should not be used for POSTs.\n    " #NEWLINE# def check_admin( self , * args , **kwargs ) : #NEWLINE# #INDENT# if ( self . request . method != 'GET' ) : #NEWLINE# #INDENT# self . abort ( 400 , detail = 'The admin_required decorator can only be used for GET requests.' ) #NEWLINE# #UNINDENT# user = users . get_current_user ( ) #NEWLINE# if ( not user ) : #NEWLINE# #INDENT# return self . redirect ( users . create_login_url ( self . request . url ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not users . is_current_user_admin ( ) ) : #NEWLINE# #INDENT# self . abort ( 403 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# handler_method ( self , * args , ** kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return check_admin