[Zope-Checkins] CVS: Zope2 - PathIndex.py:1.1.2.13
andreas@serenade.digicool.com
andreas@serenade.digicool.com
Mon, 21 May 2001 09:10:14 -0400
Update of /cvs-repository/Zope2/lib/python/Products/PluginIndexes/PathIndex
In directory serenade:/tmp/cvs-serv13056/PathIndex
Modified Files:
Tag: ajung-dropin-registry
PathIndex.py
Log Message:
fixed broken unindex code
--- Updated File PathIndex.py in package Zope2 --
--- PathIndex.py 2001/05/20 18:11:46 1.1.2.12
+++ PathIndex.py 2001/05/21 13:10:13 1.1.2.13
@@ -93,13 +93,11 @@
from OFS.SimpleItem import SimpleItem
-from BTrees.IOBTree import IOBTree
-from BTrees.OOBTree import OOBTree
+from BTrees.IOBTree import IOBTree,IOSet
+from BTrees.OOBTree import OOBTree,OOSet
from BTrees.IIBTree import IISet,difference,intersection,union
-from types import StringType
-import re,string,exceptions
+import re,exceptions
-_marker = []
class PathIndex(PluggableIndex.PluggableIndex, Persistent,
Implicit, SimpleItem):
@@ -110,7 +108,7 @@
- a physical path of an object is split into its components
- - every component is kept a key in self._indexes
+ - every component is kept as a key of a OOBTree in self._indexes
- the value is a mapping 'level of the path component' to
'all documentIds with this path component on this level'
@@ -162,8 +160,8 @@
# reverse index
if not self._unindex.has_key(id):
- self._unindex[id] = OOBTree()
- self._unindex[id][comp] = level
+ self._unindex[id] = OOSet()
+ self._unindex[id].insert( (comp,level) )
def index_object(self, documentId, obj ,threshold=100):
@@ -192,15 +190,31 @@
if not self._unindex.has_key(id):
return
- for path,level in self._unindex[id].items():
- self._index[path][level].remove(id)
+ for comp,level in self._unindex[id]:
- if len(self._index[path][level])==0:
- del self._index[path][level]
+ self._index[comp][level].remove(id)
+ if len(self._index[comp][level])==0:
+ del self._index[comp][level]
+
+ if len(self._index[comp])==0:
+ del self._index[comp]
+
del self._unindex[id]
+ def printIndex(self):
+ for k,v in self._index.items():
+ print "-"*78
+ print k
+ for k1,v1 in v.items():
+ print k1,v1,
+
+ print
+
+
+
+
def splitPath(self,path,obj=None):
""" split physical path of object. If the object has
as function splitPath() we use this user-defined function
@@ -337,8 +351,8 @@
- if type(keys) is StringType:
- if not keys or not string.strip(keys):
+ if type(keys) is type(''):
+ if not keys or not keys.strip():
return None
keys = [keys]