Update of /cvs-repository/Products/PluginIndexes/common In directory cvs.zope.org:/tmp/cvs-serv5467/lib/python/Products/PluginIndexes/common
Modified Files: Tag: Zope-2_7-branch UnIndex.py Log Message: Collector #1832: UnIndex swallowed ConflictErrors (bare 'except:' is evil). === Products/PluginIndexes/common/UnIndex.py 1.20.2.7 => 1.20.2.8 === --- Products/PluginIndexes/common/UnIndex.py:1.20.2.7 Fri May 27 09:03:50 2005 +++ Products/PluginIndexes/common/UnIndex.py Tue Jul 5 10:10:11 2005 @@ -28,6 +28,7 @@ from BTrees.IIBTree import IITreeSet, IISet, union, intersection from OFS.SimpleItem import SimpleItem import BTrees.Length +from ZODB.POSException import ConflictError from Products.PluginIndexes.common.util import parseIndexRequest from Products.PluginIndexes.common import safe_callable @@ -99,7 +100,8 @@ self.indexed_attrs = ia.split(',') else: self.indexed_attrs = list(ia) - self.indexed_attrs = [ attr.strip() for attr in self.indexed_attrs if attr ] + self.indexed_attrs = [ attr.strip() + for attr in self.indexed_attrs if attr ] if not self.indexed_attrs: self.indexed_attrs = [id] @@ -132,6 +134,7 @@ if len(s) == 1: try: return s[0] # convert to int + except ConflictError: raise except: pass # This is just an optimization. return IITreeSet(s) @@ -196,6 +199,8 @@ del self._index[entry] try: self.__len__.change(-1) except AttributeError: pass # pre-BTrees-module instance + except ConflictError: + raise except AttributeError: # index row is an int del self._index[entry] @@ -240,9 +245,7 @@ def index_object(self, documentId, obj, threshold=None): """ wrapper to handle indexing of multiple attributes """ - # needed for backward compatibility - try: fields = self.indexed_attrs - except: fields = [ self.id ] + fields = self.getIndexSourceNames() res = 0 for attr in fields: @@ -268,6 +271,8 @@ if datum is _marker: try: del self._unindex[documentId] + except ConflictError: + raise except: LOG('UnIndex', ERROR, 'Should not happen: oldDatum was there, now its not,' @@ -311,6 +316,8 @@ try: del self._unindex[documentId] + except ConflictError: + raise except: LOG('UnIndex', ERROR, 'Attempt to unindex nonexistent document' ' with id %s' % documentId) @@ -429,11 +436,7 @@ def getIndexSourceNames(self): """ return sequence of indexed attributes """ - - try: - return self.indexed_attrs - except: - return [ self.id ] + return getattr(self, 'indexed_attrs', [self.id]) def uniqueValues(self, name=None, withLengths=0): """\ _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins