예제 #1
0
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
예제 #2
0
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