Commit c0fa62a1 authored by Andreas Jung's avatar Andreas Jung

fixed potential upgrade problem due to new '_length' attribute

parent 4e7522a4
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
############################################################################## ##############################################################################
__version__ = '$Id: PathIndex.py,v 1.36 2003/08/16 16:44:42 andreasjung Exp $' __version__ = '$Id: PathIndex.py,v 1.37 2003/11/04 15:47:35 andreasjung Exp $'
import warnings import warnings
from types import StringType, ListType, TupleType from types import StringType, ListType, TupleType
...@@ -113,6 +113,7 @@ class PathIndex(Persistent, SimpleItem): ...@@ -113,6 +113,7 @@ 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)):
...@@ -147,6 +148,7 @@ class PathIndex(Persistent, SimpleItem): ...@@ -147,6 +148,7 @@ class PathIndex(Persistent, SimpleItem):
'Attempt to unindex document' 'Attempt to unindex document'
' with id %s failed' % docid) ' with id %s failed' % docid)
self._.migrate_length()
self._length.change(-1) self._length.change(-1)
del self._unindex[docid] del self._unindex[docid]
...@@ -201,12 +203,13 @@ class PathIndex(Persistent, SimpleItem): ...@@ -201,12 +203,13 @@ class PathIndex(Persistent, SimpleItem):
def numObjects(self): def numObjects(self):
""" return the number of indexed objects""" """ return the number of indexed objects"""
try: self._migrate_length()
return self._length() return self._length
except AttributeError: # backward compatibility
l = len(self._unindex) def _migrate_length(self):
self._length = Length(l) """ migrate index to use new _length attribute """
return l 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