API change: TrackingStorage.getUserTracks() - returns all entries for task/user

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1421 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2006-10-23 11:05:25 +00:00
parent 96555d9eaa
commit 97a4f080e4
3 changed files with 20 additions and 12 deletions

View file

@ -7,11 +7,12 @@ User tracking in the loops framework
>>> from cybertools.tracking.btree import TrackingStorage
>>> tracks = TrackingStorage()
>>> runId = tracks.startRun('a001')
>>> tracks.saveUserTrack('a001', runId, 'u1', {'somekey': 'somevalue'})
>>> tracks.saveUserTrack('a001', 0, 'u1', {'somekey': 'somevalue'})
'0000001'
>>> t1 = tracks.getUserTrack('a001', runId, 'u1')
>>> t1.data
>>> t1 = tracks.getUserTracks('a001', 0, 'u1')
>>> len(t1)
1
>>> t1[0].data
{'somekey': 'somevalue'}
>>> tracks.getUserNames('a001')
['u1']
@ -29,6 +30,14 @@ User tracking in the loops framework
>>> len(result)
2
What happens if we store more than on record for one set of keys?
>>> tracks.saveUserTrack('a001', 0, 'u1', {'somekey': 'newvalue'})
'0000003'
>>> t2 = tracks.getUserTracks('a001', 0, 'u1')
>>> [t.data for t in t2]
[{'somekey': 'somevalue'}, {'somekey': 'newvalue'}]
The tracks of a tracking store may be reindexed:
>>> tracks.reindexTracks()

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2005 Helmut Merz helmutm@cy55.de
# Copyright (c) 2006 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -90,11 +90,10 @@ class TrackingStorage(BTreeContainer):
trackNum = int(trackId)
self.indexTrack(trackNum, self[trackId])
def getUserTrack(self, taskId, runId, userName):
def getUserTracks(self, taskId, runId, userName):
if not runId:
runId = self.currentRuns.get(taskId)
tracks = self.query(taskId=taskId, runId=runId, userName=userName)
return tracks and tracks[0] or None
return self.query(taskId=taskId, runId=runId, userName=userName)
def query(self, **kw):
result = None

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2005 Helmut Merz helmutm@cy55.de
# Copyright (c) 2006 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -58,9 +58,9 @@ class ITrackingStorage(Interface):
userName, timeFrom, timeTo.
"""
def getUserTrack(taskId, runId, userName):
""" Return the user track data corresponding to the user name and
task id given. If no run id is given use the current one.
def getUserTracks(taskId, runId, userName):
""" Return the user tracks corresponding to the user name and
task id given. If a 0 run id is given use the current one.
"""
def getUserNames(taskId):