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:
parent
96555d9eaa
commit
97a4f080e4
3 changed files with 20 additions and 12 deletions
|
@ -7,11 +7,12 @@ User tracking in the loops framework
|
||||||
>>> from cybertools.tracking.btree import TrackingStorage
|
>>> from cybertools.tracking.btree import TrackingStorage
|
||||||
|
|
||||||
>>> tracks = TrackingStorage()
|
>>> tracks = TrackingStorage()
|
||||||
>>> runId = tracks.startRun('a001')
|
>>> tracks.saveUserTrack('a001', 0, 'u1', {'somekey': 'somevalue'})
|
||||||
>>> tracks.saveUserTrack('a001', runId, 'u1', {'somekey': 'somevalue'})
|
|
||||||
'0000001'
|
'0000001'
|
||||||
>>> t1 = tracks.getUserTrack('a001', runId, 'u1')
|
>>> t1 = tracks.getUserTracks('a001', 0, 'u1')
|
||||||
>>> t1.data
|
>>> len(t1)
|
||||||
|
1
|
||||||
|
>>> t1[0].data
|
||||||
{'somekey': 'somevalue'}
|
{'somekey': 'somevalue'}
|
||||||
>>> tracks.getUserNames('a001')
|
>>> tracks.getUserNames('a001')
|
||||||
['u1']
|
['u1']
|
||||||
|
@ -29,6 +30,14 @@ User tracking in the loops framework
|
||||||
>>> len(result)
|
>>> len(result)
|
||||||
2
|
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:
|
The tracks of a tracking store may be reindexed:
|
||||||
|
|
||||||
>>> tracks.reindexTracks()
|
>>> tracks.reindexTracks()
|
||||||
|
|
|
@ -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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -90,11 +90,10 @@ class TrackingStorage(BTreeContainer):
|
||||||
trackNum = int(trackId)
|
trackNum = int(trackId)
|
||||||
self.indexTrack(trackNum, self[trackId])
|
self.indexTrack(trackNum, self[trackId])
|
||||||
|
|
||||||
def getUserTrack(self, taskId, runId, userName):
|
def getUserTracks(self, taskId, runId, userName):
|
||||||
if not runId:
|
if not runId:
|
||||||
runId = self.currentRuns.get(taskId)
|
runId = self.currentRuns.get(taskId)
|
||||||
tracks = self.query(taskId=taskId, runId=runId, userName=userName)
|
return self.query(taskId=taskId, runId=runId, userName=userName)
|
||||||
return tracks and tracks[0] or None
|
|
||||||
|
|
||||||
def query(self, **kw):
|
def query(self, **kw):
|
||||||
result = None
|
result = None
|
||||||
|
|
|
@ -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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -58,9 +58,9 @@ class ITrackingStorage(Interface):
|
||||||
userName, timeFrom, timeTo.
|
userName, timeFrom, timeTo.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def getUserTrack(taskId, runId, userName):
|
def getUserTracks(taskId, runId, userName):
|
||||||
""" Return the user track data corresponding to the user name and
|
""" Return the user tracks corresponding to the user name and
|
||||||
task id given. If no run id is given use the current one.
|
task id given. If a 0 run id is given use the current one.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def getUserNames(taskId):
|
def getUserNames(taskId):
|
||||||
|
|
Loading…
Add table
Reference in a new issue