Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions dbzero/dbzero/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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('.')
Expand Down