def find_all_by_destination(session, destination, destination_id): if not QueryHelper.destination_exists(destination): return [] query = QueryHelper(session).select_destination(destination, destination_id) func_key_rows = query.all() return [db_converter.to_model(row) for row in func_key_rows]
def get(session, func_key_id): query = QueryHelper(session).select_func_key(func_key_id) row = query.first() if not row: raise errors.not_found('FuncKey', id=func_key_id) return db_converter.to_model(row)
def get(session, func_key_id): query = QueryHelper(session).select_func_key(func_key_id) row = query.first() if not row: raise ElementNotExistsError('FuncKey') return db_converter.to_model(row)
def delete(session, func_key): helper = QueryHelper(session) func_key_query = helper.delete_func_key(func_key.id) destination_query = helper.delete_destination(func_key.destination, func_key.destination_id) with commit_or_abort(session, DataError.on_delete, 'FuncKey'): destination_query.delete() func_key_query.delete()
def delete(session, func_key): helper = QueryHelper(session) func_key_query = helper.delete_func_key(func_key.id) destination_query = helper.delete_destination(func_key.destination, func_key.destination_id) with commit_or_abort(session, ElementDeletionError, 'FuncKey'): destination_query.delete() func_key_query.delete()
def search(session, **parameters): rows, total = QueryHelper(session).search(parameters) func_keys = [db_converter.to_model(row) for row in rows] return SearchResult(total, func_keys)