def get_item(cls, id, request): if oauth.check_auth(request) is None: return '', 401 check = cls.check_id(id) if not isinstance(check, int): return check return cls(check).json()
def get_me(): user_id = oauth.check_auth(request) #user_id = 0 if user_id is None: return '', 401 answer = user.User(user_id).json()[0] cases = case.Case.db()(user_id=user_id) for item in cases: answer += case.Case(item['__id__']).json()[0] return answer
def get_me(): user_id = oauth.check_auth(request) #user_id = 0 if user_id is None: return '', 401 answer = owner.Owner(user_id).json()[0] pets = pet.Pet.db()(owner_id = user_id) for item in pets: answer += pet.Pet(item['__id__']).json()[0] return answer
def post_item(cls, request): if oauth.check_auth(request) is None: return '', 401 try: id = cls.insert_db(cls, request) cls.db().commit() except: return '', 400 return '', 201, {'Location': '/' + cls.name + '/{}'.format(id)}
def post_item(cls, request): if oauth.check_auth(request) is None: return '', 401 try: id = cls.insert_db(cls, request) cls.db().commit() except: return '', 400 return '', 201, { 'Location': '/' + cls.name + '/{}'.format(id) }
def put_item(cls, id, request): if oauth.check_auth(request) is None: return '', 401 check = cls.check_id(id) if not isinstance(check, int): return check try: cls.update_db(cls, cls.db()[check], request) cls.db().commit() except: return '', 400 return '', 200