def update(self, uuid, update_dict): model = self.model_class.get(uuid) if not model: raise ResourceNotFoundError('Not found') model = model.update(update_dict) model.persist() get_db_session().commit() return model
def save(self, model): database.get_db_session('write').add(model) database.get_db_session('write').commit() database.get_db_session('read').expunge_all()
def persist(self): get_db_session().add(self)
def query(cls): return get_db_session().query(cls)
def create_from_entity(self, entity): entity.validate() entity.persist() get_db_session().commit() return entity