diff options
Diffstat (limited to 'src-py')
| -rw-r--r-- | src-py/db_controller.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src-py/db_controller.py b/src-py/db_controller.py index 1e80ff84..9a6151ec 100644 --- a/src-py/db_controller.py +++ b/src-py/db_controller.py @@ -74,9 +74,33 @@ class DB_op(object): pass def on_completion(self, data): + pass + + def _assign_results_errors(self, data): self.result_set = data['results'] self.error_set = data['errors'] +class DB_composed_op(DB_op): + def __init__(self): + super(DB_composed_op, self).__init__() + self.sub_op_set = [] + + def add_statement(self, query, query_params={}): + assert False, "composed_op may not contain statements, only sub-ops" + + def add_sub_op(self, op): + self.sub_op_set.append(op) + + def __getattribute__(self, attr): + """ + intercept 'statement_set' attr get + """ + if attr == 'statement_set': + # construct a list comprehension composed of all sup_op statements + return [s for s_op in self.sub_op_set for s in s_op.statement_set] + + return object.__getattribute__(self, attr) + pass class DBO_add_node_set(DB_op): |
