def require_cron_or_superadmin(handler):
 def _require_cron_or_superadmin(self, *args, **kwargs):
  if ((self.request.headers.get('X-AppEngine-Cron') is None) and (not self.is_super_admin)):
   raise self.UnauthorizedUserException('You do not have the credentials to access this page.')
  else:
   return handler(self, *args, **kwargs)
 return _require_cron_or_superadmin

def require_cron_or_superadmin ( handler ) : def _require_cron_or_superadmin ( self , * args , ** kwargs ) : if ( ( self . request . headers . get ( 'X-AppEngine-Cron' ) is None ) and ( not self . is_super_admin ) ) : raise self . UnauthorizedUserException ( 'You do not have the credentials to access this page.' ) else : return handler ( self , * args , ** kwargs ) return _require_cron_or_superadmin
decorator to ensure that the handler is being called by cron or by a superadmin of the application .