Commit da8f819a authored by Andreas Jung's avatar Andreas Jung

Collector #449: PathIndex did not index last part of path

parent a53e7d3f
......@@ -6,6 +6,8 @@ Zope Changes
Bugs Fixed
- Collector #449: PathIndex did not index the last part of path.
- Collector #539: Fixed rendering of TAL namespace tags with an
'on-error' statement.
......
......@@ -11,7 +11,7 @@
#
##############################################################################
__version__ = '$Id: PathIndex.py,v 1.26 2002/09/24 11:03:24 andreasjung Exp $'
__version__ = '$Id: PathIndex.py,v 1.27 2002/10/03 13:10:49 andreasjung Exp $'
from Products.PluginIndexes import PluggableIndex
from Products.PluginIndexes.common.util import parseIndexRequest
......@@ -126,8 +126,8 @@ class PathIndex(Persistent, Implicit, SimpleItem):
comps = self.splitPath(path,obj)
if obj.meta_type != 'Folder':
comps = comps[:-1]
# if obj.meta_type != 'Folder':
# comps = comps[:-1]
for i in range(len(comps)):
self.insertEntry( comps[i],documentId,i)
......@@ -146,7 +146,7 @@ class PathIndex(Persistent, Implicit, SimpleItem):
path = self._unindex[documentId]
comps = path.split('/')
for level in range(len(comps[1:])-1):
for level in range(len(comps[1:])):
comp = comps[level+1]
self._index[comp][level].remove(documentId)
......@@ -190,8 +190,8 @@ class PathIndex(Persistent, Implicit, SimpleItem):
relative URL or a part of a relative URL or
a tuple (path,level).
level >= 0 starts searching at the given level
level < 0 not implemented yet
level>=0 starts searching at the given level
level<0 not implemented yet
"""
if isinstance(path,StringType):
......@@ -202,10 +202,7 @@ class PathIndex(Persistent, Implicit, SimpleItem):
comps = self.splitPath(path)
if len(comps) == 0:
return IISet(self._unindex.keys())
if level >= 0:
if level >=0:
results = []
for i in range(len(comps)):
......@@ -228,7 +225,7 @@ class PathIndex(Persistent, Implicit, SimpleItem):
results = IISet()
for level in range(0,self._depth):
for level in range(0,self._depth + 1):
ids = None
error = 0
......@@ -238,7 +235,7 @@ class PathIndex(Persistent, Implicit, SimpleItem):
try:
ids = intersection(ids,self._index[comp][level+cn])
except:
except KeyError:
error = 1
if error==0:
......
......@@ -53,8 +53,8 @@ class TestCase( unittest.TestCase ):
14 : Dummy("/bb/bb/bb/14.html"),
15 : Dummy("/bb/bb/cc/15.html"),
16 : Dummy("/bb/cc/aa/16.html"),
17 : Dummy("/bb/cc/bb/17html"),
18 : Dummy("/bb/cc/cc/18html")
17 : Dummy("/bb/cc/bb/17.html"),
18 : Dummy("/bb/cc/cc/18.html")
}
def _populateIndex(self):
......@@ -84,16 +84,21 @@ class TestCase( unittest.TestCase ):
self._populateIndex()
tests = [
("aa",0, [1,2,3,4,5,6,7,8,9]),
("aa",1, [1,2,3,10,11,12] ),
("bb",0, [10,11,12,13,14,15,16,17,18]),
("bb",1, [4,5,6,13,14,15] ),
("bb/cc",0, [16,17,18] ),
("bb/cc",1, [6,15] ),
("bb/aa",0, [10,11,12] ),
("bb/aa",1, [4,13] ),
("aa/cc",-1, [3,7,8,9,12] ),
("bb/bb",-1, [5,13,14,15] )
("aa", 0, [1,2,3,4,5,6,7,8,9]),
("aa", 1, [1,2,3,10,11,12] ),
("bb", 0, [10,11,12,13,14,15,16,17,18]),
("bb", 1, [4,5,6,13,14,15] ),
("bb/cc", 0, [16,17,18] ),
("bb/cc", 1, [6,15] ),
("bb/aa", 0, [10,11,12] ),
("bb/aa", 1, [4,13] ),
("aa/cc", -1, [3,7,8,9,12] ),
("bb/bb", -1, [5,13,14,15] ),
("18.html", 3, [18] ),
("18.html", -1, [18] ),
("cc/18.html", -1, [18] ),
("cc/18.html", 2, [18] ),
]
for comp,level,results in tests:
......@@ -146,3 +151,9 @@ class TestCase( unittest.TestCase ):
def test_suite():
return unittest.makeSuite( TestCase )
def main():
unittest.TextTestRunner().run(test_suite())
if __name__ == '__main__':
main()
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