diff --git a/organize/interfaces.py b/organize/interfaces.py index b0bd4b3..58ed910 100644 --- a/organize/interfaces.py +++ b/organize/interfaces.py @@ -493,7 +493,21 @@ class IWorkItems(Interface): """ A collection (manager, container) of work items. """ + def __getitem__(key): + """ Return the work item identified by the key given. + """ + + def __iter__(): + """ Return an iterator of all work items. + """ + + def query(**criteria): + """ Search for tracks. Possible criteria are: task, party, run, + timeFrom, timeTo. + """ + def add(task, party, run=0, **kw): """ Create and register a work item; return it. Additional properties may be specified via keyword arguments. """ + diff --git a/organize/work.py b/organize/work.py index e389c29..b10d2a7 100644 --- a/organize/work.py +++ b/organize/work.py @@ -228,6 +228,15 @@ class WorkItems(object): def __iter__(self): return iter(self.context.values()) + def query(self, **criteria): + if 'task' in criteria: + criteria['taskId'] = criteria.pop('task') + if 'party' in criteria: + criteria['userName'] = criteria.pop('party') + if 'run' in criteria: + criteria['runId'] = criteria.pop('run') + return self.context.query(**criteria) + def add(self, task, party, run=0, **kw): trackId = self.context.saveUserTrack(task, run, party, {}) track = self[trackId]