def prepare(context: Context, action: str, model: Model, backend: PostgreSQL, value: RowProxy) -> RowProxy: if action == 'getall': row = {k: v for k, v in value.items() if not k.startswith('_')} row['id'] = str(row['id']) return row elif action == 'getone': result = {k: v for k, v in value.items() if not k.startswith('_')} result['type'] = model.name result['id'] = str(result['id']) return result
def dump_rowproxy(rowproxy: RowProxy, exclude: list = None): dump = dict([(k, v) for k, v in rowproxy.items() if not k.startswith('_')]) if exclude: for key in exclude: if dump.get(key): dump.pop(key) return dump