示例#1
0
 def __init__(self, request):
     self.request = request
     self.auth = auth.Authenticator(self)
     try:
         if not self.request.body.strip():
             self.body = None
         else:
             self.body = json.loads(self.request.body)
     except:
         abort('Request body must be JSON')
示例#2
0
    def require_entity(self, cls):
        user = self.get_current_user()
        if not user.is_worker():
            abort(failure('Invalid credentials: must be a valid worker'))

        worker = cls.get_by_id(user.id)
        if worker is None:
            abort(failure('Invalid credentials: must be a valid worker'))

        return worker
示例#3
0
 def __init__(self, request):
     self.request = request
     self.auth = auth.Authenticator(self)
     try:
         if not self.request.body.strip():
             self.body = None
         else:
             self.body = json.loads(self.request.body)
     except:
         abort("Request body must be JSON")
示例#4
0
 def get_or_abort(self, param):
     result = self.request.get(param, None)
     if result is None:
         abort('Required parameter \'%s\' is missing' % param)
     return result
示例#5
0
 def get_by_id_or_abort(cls, *args, **kwargs):
   res = cls.get_by_id(*args, **kwargs)
   if res is None:
     abort('%s not found' % cls.__name__)
   return res
示例#6
0
 def get_by_id_or_abort(cls, *args, **kwargs):
     res = cls.get_by_id(*args, **kwargs)
     if res is None:
         abort("%s not found" % cls.__name__)
     return res
示例#7
0
 def get_or_abort(self, param):
     result = self.request.get(param, None)
     if result is None:
         abort("Required parameter '%s' is missing" % param)
     return result