diff options
| author | LV-426 <lv-426@taproot.org.il> | 2014-10-15 18:37:00 +0200 |
|---|---|---|
| committer | LV-426 <lv-426@taproot.org.il> | 2014-10-15 18:37:00 +0200 |
| commit | 93873bd93ccc8463eaa3931e1efe7d30d1007e0b (patch) | |
| tree | d843c564d2b99137d2265c1aef2fdceff6ed903c /src-py | |
| parent | b6824dd09a58d2e400851fc310b416f4311bd030 (diff) | |
DB_composed_op
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): |
