[CMF-checkins] CVS: Products/CMFCore - CatalogTool.py:1.65

Yvo Schubbe y.2005- at wcm-solutions.de
Thu Jul 7 14:14:51 EDT 2005


Update of /cvs-repository/Products/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv5547/CMFCore

Modified Files:
	CatalogTool.py 
Log Message:
added latest manage_convertIndexes from Zope-2_8-branch to override the broken one from Zope 2.8.0


=== Products/CMFCore/CatalogTool.py 1.64 => 1.65 ===
--- Products/CMFCore/CatalogTool.py:1.64	Thu Jul  7 13:24:57 2005
+++ Products/CMFCore/CatalogTool.py	Thu Jul  7 14:14:50 2005
@@ -20,6 +20,7 @@
 from DateTime import DateTime
 from Globals import DTMLFile
 from Globals import InitializeClass
+from Products.ZCatalog.ZCatalog import LOG
 from Products.ZCatalog.ZCatalog import ZCatalog
 from Products.ZCTextIndex.HTMLSplitter import HTMLWordSplitter
 from Products.ZCTextIndex.Lexicon import CaseNormalizer
@@ -330,5 +331,64 @@
             valid_indexes = self._catalog.indexes.keys()
             idxs = [i for i in idxs if i in valid_indexes]
         self.catalog_object(object, url, idxs, update_metadata)
+
+    # BBB: for Zope 2.8.0
+    # copied from revision 31005 of ZCatalog.py
+    def manage_convertIndexes(self, REQUEST=None, RESPONSE=None, URL1=None):
+        """Recreate indexes derived from UnIndex because the implementation of
+           __len__ changed in Zope 2.8. Pre-Zope 2.7 installation used to implement
+           __len__ as persistent attribute of the index instance which is totally
+           incompatible with the new extension class implementation based on new-style
+           classes. 
+        """
+
+        LOG.info('Start migration of indexes for %s' % self.absolute_url(1))
+        
+        reindex_ids = []
+
+        for idx in self.Indexes.objectValues():
+            bases = [str(name) for name in idx.__class__.__bases__]
+            found = False
+
+            if idx.meta_type  == 'PathIndex':
+                found = True
+            else:
+                for base in bases:
+                    if 'UnIndex' in base:
+                        found = True
+                        break
+
+            if found:
+                idx_type = idx.meta_type
+                idx_id = idx.getId()
+                LOG.info('processing index %s' % idx_id)
+
+                indexed_attrs = getattr(idx, 'indexed_attrs', None)
+
+                if idx.meta_type == 'DateRangeIndex':
+                    since_field = getattr(idx, '_since_field', None)
+                    until_field = getattr(idx, '_until_field', None)
+
+                self.delIndex(idx.getId())
+                self.addIndex(idx_id, idx_type)
+                new_idx = self.Indexes[idx_id]
+
+                if indexed_attrs:
+                    setattr(new_idx, 'indexed_attrs', indexed_attrs)
+                if idx.meta_type == 'DateRangeIndex':
+                    setattr(new_idx, '_since_field',  since_field)
+                    setattr(new_idx, '_until_field', until_field)
+                reindex_ids.append(idx_id)
+        
+        if reindex_ids:
+            LOG.info('Reindexing %s' % ', '.join(reindex_ids))
+            self.manage_reindexIndex(reindex_ids, REQUEST)
+
+        self._migrated_280 = True
+        LOG.info('Finished migration of indexes for %s' % self.absolute_url(1))
+
+        if RESPONSE:
+            RESPONSE.redirect( URL1 +
+            '/manage_main?manage_tabs_message=Indexes%20converted%20and%20reindexed')
 
 InitializeClass(CatalogTool)



More information about the CMF-checkins mailing list