Commit 27b075f8 authored by Andreas Jung's avatar Andreas Jung

- added getEntryForObject()

- internal inverse index reworked
parent 1da1319e
......@@ -54,6 +54,9 @@ Zope Changes
- Added updated and enhanced testsuite for STXNG.
- added getEntryForObject() for PathIndexes. Reworked PathIndex's
internal inverse index.
Bugs fixed
- Collector #2532: ZCatalog.availableSplitters is now protected
......
......@@ -83,7 +83,7 @@
#
##############################################################################
__version__ = '$Id: PathIndex.py,v 1.8 2001/10/03 13:11:02 andreasjung Exp $'
__version__ = '$Id: PathIndex.py,v 1.9 2001/10/12 20:02:15 andreasjung Exp $'
from Products.PluginIndexes import PluggableIndex
from Products.PluginIndexes.common.util import parseIndexRequest
......@@ -100,6 +100,8 @@ from BTrees.IIBTree import IISet,difference,intersection,union
from types import StringType, ListType, TupleType
import re,warnings
_marker = []
class PathIndex(PluggableIndex.PluggableIndex, Persistent,
Implicit, SimpleItem):
......@@ -205,18 +207,23 @@ class PathIndex(PluggableIndex.PluggableIndex, Persistent,
for i in range(len(comps)):
self.insertEntry( comps[i],documentId,i)
return 1
self._unindex[documentId] = path
return 1
def unindex_object(self,id):
def unindex_object(self,documentId):
""" hook for (Z)Catalog """
if not self._unindex.has_key(id):
return
if not self._unindex.has_key(documentId):
return
for comp,level in self._unindex[id]:
path = self._unindex[documentId]
comps = path.split('/')
self._index[comp][level].remove(id)
for level in range(len(comps[1:])-1):
comp = comps[level+1]
self._index[comp][level].remove(documentId)
if len(self._index[comp][level])==0:
del self._index[comp][level]
......@@ -224,7 +231,10 @@ class PathIndex(PluggableIndex.PluggableIndex, Persistent,
if len(self._index[comp])==0:
del self._index[comp]
del self._unindex[id]
del self._unindex[documentId]
def printIndex(self):
......@@ -395,6 +405,15 @@ class PathIndex(PluggableIndex.PluggableIndex, Persistent,
""" needed to be consistent with the interface """
return self._index.keys()
def getEntryForObject(self,documentId,default=_marker):
""" Takes a document ID and returns all the information we have
on that specific object. """
try:
return self._unindex[documentId]
except:
return None
index_html = DTMLFile('dtml/index', globals())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment