#NEWLINE# def administrator( method ) : #NEWLINE# #INDENT# 'Decorate with this method to restrict to site admins.' #NEWLINE# @ functools . wraps ( method ) #NEWLINE# def wrapper( self , * args , **kwargs ) : #NEWLINE# #INDENT# if ( not self . current_user ) : #NEWLINE# #INDENT# if ( self . request . method == 'GET' ) : #NEWLINE# #INDENT# self . redirect ( self . get_login_url ( ) ) #NEWLINE# return #NEWLINE# #UNINDENT# raise tornado . web . HTTPError ( 403 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not self . current_user . administrator ) : #NEWLINE# #INDENT# if ( self . request . method == 'GET' ) : #NEWLINE# #INDENT# self . redirect ( '/' ) #NEWLINE# return #NEWLINE# #UNINDENT# raise tornado . web . HTTPError ( 403 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return method ( self , * args , ** kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return method