diff --git a/dbzero/dbzero/decorators.py b/dbzero/dbzero/decorators.py index d42b5392..14cd80e2 100644 --- a/dbzero/dbzero/decorators.py +++ b/dbzero/dbzero/decorators.py @@ -31,6 +31,20 @@ def wrapper(*args, **kwargs): wrapper.__db0_fulltext = True return wrapper +def table_view(f, operator=None): + """The table_view decorator marks a specific function or method as generating a table view. The following properties apply: + - First result represents the table header + - All other results (rows) are key-decorated (i.e. return tuples with unique identifiers) - see Cell Editor + - Optional operator may be defined to allow cell editions (see Cell Operator) + """ + @functools.wraps(f) + def wrapper(*args, **kwargs): + retval = f(*args, **kwargs) + return retval + # Immutable query if True and immutable parameter if false + wrapper.__db0_table_view = True + return wrapper + def is_immutable(f): return hasattr(f, '__db0_immutable_query') @@ -46,6 +60,9 @@ def is_query(f): def is_fulltext(f): return hasattr(f, '__db0_fulltext') +def is_table_view(f): + return hasattr(f, '__db0_table_view') + def _get_function_context(f): context = sys.modules[f.__module__] path = f.__qualname__.split('.')