diff --git a/larigira/db.py b/larigira/db.py index a36468b..ea3cff7 100644 --- a/larigira/db.py +++ b/larigira/db.py @@ -24,12 +24,12 @@ class ReadOnlyException(ValueError): def only_main(f): '''assumes first argument is id, and must be "main"''' - def wrapper(self, *args): + def wrapper(self, *args, **kwargs): _id = args[0] db, db_id = EventModel.parse_id(_id) if db != 'main': raise ReadOnlyException('You called a write operation on a readonly db') - return f(self, db_id, *args[1:]) + return f(self, db_id, *args[1:], **kwargs) return wrapper @@ -79,7 +79,7 @@ class EventModel(object): int(eid_or_aid) except ValueError: return eid_or_aid - return 'main:%d' % eid_or_aid + return 'main:%d' % int(eid_or_aid) @staticmethod def parse_id(eid_or_aid: Union[str, int]) -> Tuple[str, int]: @@ -121,7 +121,9 @@ class EventModel(object): def get_all_actions(self) -> list: out = [] for db in self._dbs: - out.extend(self._dbs[db].table('actions').all()) + for action in self._dbs[db].table('actions').all(): + action.doc_id = '%s:%s' % (db, action.doc_id) + out.append(action) return out def get_all_alarms_expanded(self):