예제 #1
0
 def create_user(self, arg_dict):
     try:
         user = User(**arg_dict)
     except AssertionError as ex:
         raise falcon.HTTPBadRequest('Could not create User.', ex.message)
     try:
         return user.save()
     except (IntegrityError, InvalidRequestError) as ex:
         DB.rollback()
         raise falcon.HTTPBadRequest('Could not create User.', 'That email is already taken.')
예제 #2
0
파일: models.py 프로젝트: Rdbaker/Rovu-API
 def query(cls):
     return DB.query(cls)
예제 #3
0
파일: models.py 프로젝트: Rdbaker/Rovu-API
 def delete(self, commit=True):
     """Remove the record from the database."""
     DB.delete(self)
     return commit and DB.commit()
예제 #4
0
파일: models.py 프로젝트: Rdbaker/Rovu-API
 def save(self, commit=True):
     """Save the record."""
     DB.add(self)
     if commit:
         DB.commit()
     return self
예제 #5
0
파일: models.py 프로젝트: Rdbaker/Rovu-API
 def get(cls, id):
     """Get an instance from its id."""
     return DB.query(cls).get(id)
예제 #6
0
 def _query_collection(self, cls, schema):
     """Query a collection of a class passed in and return the JSON dump of its schema"""
     return json.dumps(json.loads(schema.dumps(DB.query(cls).all(), many=True).data))