def taskqueue_method(handler):
 def check_if_taskqueue(self, *args, **kwargs):
  '\n         Check if it is executed by Taskqueue in Staging or Production\n         Allow run in localhost calling the url\n        '
  if ((self.request.headers.get('X-AppEngine-TaskName') is None) and (config.get('environment') == 'production') and (not users.is_current_user_admin())):
   return self.error(403)
  else:
   return handler(self, *args, **kwargs)
 return check_if_taskqueue

def taskqueue_method ( handler ) : def check_if_taskqueue ( self , * args , ** kwargs ) : if ( ( self . request . headers . get ( 'X-AppEngine-TaskName' ) is None ) and ( config . get ( 'environment' ) == 'production' ) and ( not users . is_current_user_admin ( ) ) ) : return self . error ( 403 ) else : return handler ( self , * args , ** kwargs ) return check_if_taskqueue
decorator to indicate that this is a taskqueue method and applies request .