unindex track on removal
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3100 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
3530b7045a
commit
1f4985c996
2 changed files with 23 additions and 5 deletions
|
@ -26,12 +26,15 @@ import time
|
|||
from persistent import Persistent
|
||||
from BTrees import OOBTree, IOBTree
|
||||
from BTrees.IFBTree import intersection, union
|
||||
from zope.component import adapter
|
||||
from zope.interface import implements
|
||||
from zope.app.container.btree import BTreeContainer
|
||||
from zope.app.container.interfaces import IObjectRemovedEvent
|
||||
from zope.index.field import FieldIndex
|
||||
from zope.traversing.api import getParent
|
||||
from zope.traversing.interfaces import IPhysicallyLocatable
|
||||
|
||||
from interfaces import IRun, ITrackingStorage, ITrack
|
||||
from cybertools.tracking.interfaces import IRun, ITrackingStorage, ITrack
|
||||
|
||||
|
||||
class Run(object):
|
||||
|
@ -53,7 +56,8 @@ class Run(object):
|
|||
|
||||
class Track(Persistent):
|
||||
|
||||
implements(ITrack, IPhysicallyLocatable)
|
||||
#implements(ITrack, IPhysicallyLocatable)
|
||||
implements(ITrack)
|
||||
|
||||
metadata_attributes = ('taskId', 'runId', 'userName', 'timeStamp')
|
||||
index_attributes = metadata_attributes
|
||||
|
@ -72,8 +76,8 @@ class Track(Persistent):
|
|||
self.timeStamp = getTimeStamp()
|
||||
self.data = data
|
||||
|
||||
def getName(self):
|
||||
return self.__name__
|
||||
#def getName(self):
|
||||
# return self.__name__
|
||||
|
||||
def update(self, newData):
|
||||
if not newData:
|
||||
|
@ -225,8 +229,13 @@ class TrackingStorage(BTreeContainer):
|
|||
self.taskUsers[taskId] = OOBTree.OOTreeSet()
|
||||
self.taskUsers[taskId].update([userName])
|
||||
|
||||
def unindexTrack(self, trackNum, track):
|
||||
for attr in self.indexAttributes:
|
||||
self.indexes[attr].unindex_doc(trackNum)
|
||||
|
||||
def reindexTracks(self):
|
||||
# TODO: clear indexes
|
||||
for attr in self.trackFactory.index_attributes:
|
||||
self.indexes[attr].clear()
|
||||
for trackId in self:
|
||||
trackNum = int(trackId)
|
||||
self.indexTrack(trackNum, self[trackId])
|
||||
|
@ -285,3 +294,8 @@ def timeStamp2ISO(ts):
|
|||
|
||||
def getTimeStamp():
|
||||
return int(time.time())
|
||||
|
||||
|
||||
@adapter(ITrack, IObjectRemovedEvent)
|
||||
def unindexTrack(context, event):
|
||||
getParent(context).unindexTrack(int(context.__name__), context)
|
||||
|
|
|
@ -46,6 +46,10 @@ class ITrack(Interface):
|
|||
metadata = Attribute('A mapping with the track\'s metadata')
|
||||
indexdata = Attribute('A mapping with the data to be used for indexing')
|
||||
|
||||
#def getName():
|
||||
# """ Return the internal name (ID) of the track.
|
||||
# """
|
||||
|
||||
|
||||
class ITrackingStorage(Interface):
|
||||
""" A utility for storing user tracks.
|
||||
|
|
Loading…
Add table
Reference in a new issue