Commit cbb57740 authored by Andreas Jung's avatar Andreas Jung

added indexSize(), __len__()

parent 156c06e8
...@@ -113,7 +113,6 @@ class PathIndex(Persistent, SimpleItem): ...@@ -113,7 +113,6 @@ class PathIndex(Persistent, SimpleItem):
comps = filter(None, path.split('/')) comps = filter(None, path.split('/'))
if not self._unindex.has_key(docid): if not self._unindex.has_key(docid):
self._migrate_length()
self._length.change(1) self._length.change(1)
for i in range(len(comps)): for i in range(len(comps)):
...@@ -146,7 +145,6 @@ class PathIndex(Persistent, SimpleItem): ...@@ -146,7 +145,6 @@ class PathIndex(Persistent, SimpleItem):
LOG.error('Attempt to unindex document with id %s failed' LOG.error('Attempt to unindex document with id %s failed'
% docid) % docid)
self._migrate_length()
self._length.change(-1) self._length.change(-1)
del self._unindex[docid] del self._unindex[docid]
...@@ -200,14 +198,15 @@ class PathIndex(Persistent, SimpleItem): ...@@ -200,14 +198,15 @@ class PathIndex(Persistent, SimpleItem):
return results return results
def numObjects(self): def numObjects(self):
""" return the number distinct values """
return len(self._unindex)
def indexSize(self):
""" return the number of indexed objects""" """ return the number of indexed objects"""
self._migrate_length() return len(self)
return self._length()
def _migrate_length(self): def __len__(self):
""" migrate index to use new _length attribute """ return self._length()
if not hasattr(self, '_length'):
self._length = Length(len(self._unindex))
def _apply_index(self, request, cid=''): def _apply_index(self, request, cid=''):
""" hook for (Z)Catalog """ hook for (Z)Catalog
......
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