[Zope-Checkins] CVS: Zope/lib/python/Products/ZCatalog - Catalog.py:1.79
Andreas Jung
andreas@zope.com
Tue, 13 Nov 2001 15:34:04 -0500
Update of /cvs-repository/Zope/lib/python/Products/ZCatalog
In directory cvs.zope.org:/tmp/cvs-serv5291
Modified Files:
Catalog.py
Log Message:
removed 'batch-size' crap (not used inside Zope)
=== Zope/lib/python/Products/ZCatalog/Catalog.py 1.78 => 1.79 ===
elif REQUEST: kw=REQUEST
- # Make sure batch size is set
- if REQUEST and not REQUEST.has_key('batch_size'):
- try: batch_size=self.default_batch_size
- except AttributeError: batch_size=20
- REQUEST['batch_size']=batch_size
-
# Compute "sort_index", which is a sort index, or none:
if kw.has_key('sort-on'):
sort_index=kw['sort-on']
@@ -680,6 +674,49 @@
return r
__call__ = searchResults
+
+
+ def checkConsistency(self):
+ """ perform some consistency checks on the catalog """
+ from types import IntType
+ from BTrees.IIBTree import IISet,difference,intersection
+
+ l_data = list(self.data.keys())
+ l_data.sort()
+ l_uids = list(self.uids.values())
+ l_uids.sort()
+ l_paths = list(self.data.keys())
+ l_paths.sort()
+
+ assert l_data == l_uids
+ assert l_data == l_paths
+
+ for id,idx in self.indexes.items():
+
+ if idx.meta_type == 'FieldIndex':
+
+ RIDS = IISet()
+ for key, rids in idx._index.items():
+ if isinstance(rids,IntType):
+ RIDS.insert( rids )
+ else:
+ map(RIDS.insert , rids.keys())
+
+ diff = difference(RIDS, IISet(self.data.keys()))
+ assert len(diff)==0,'Index %s: problem with forward entries' % id
+
+
+ RIDS = IISet()
+ for key, rids in idx._index.items():
+ if isinstance(rids,IntType):
+ RIDS.insert( rids )
+ else:
+ map(RIDS.insert , rids.keys())
+
+ diff = difference(RIDS, IISet(self.data.keys()))
+ assert len(diff)==0,'Index %s: problems with backward entries' % id
+
+
class CatalogError(Exception): pass