[Checkins] SVN: CMF/branches/2.1/CMFCore/Extensions/migrateToCMF21.py Add code to unregister utilities

Wichert Akkerman wichert at wiggy.net
Thu Jul 12 11:41:05 EDT 2007


Log message for revision 77759:
  Add code to unregister utilities

Changed:
  U   CMF/branches/2.1/CMFCore/Extensions/migrateToCMF21.py

-=-
Modified: CMF/branches/2.1/CMFCore/Extensions/migrateToCMF21.py
===================================================================
--- CMF/branches/2.1/CMFCore/Extensions/migrateToCMF21.py	2007-07-12 15:34:40 UTC (rev 77758)
+++ CMF/branches/2.1/CMFCore/Extensions/migrateToCMF21.py	2007-07-12 15:41:04 UTC (rev 77759)
@@ -17,6 +17,8 @@
 $Id$
 """
 
+from zope.component import getSiteManager
+from zope.dottedname.resolve import resolve
 from logging import getLogger
 import sys
 import transaction
@@ -32,6 +34,22 @@
     , 'Products.CMFActionIcons:actionicons' : 'portal_actionicons'
     }
 
+# These are utilities that were registered in CMF 2.1 pre-releases but
+# are no longer present.
+BAD_UTILITIES = [
+    'Products.CMFCalendar.interfaces.ICalendarTool',
+    'Products.CMFCore.interfaces.IActionsTool',
+    'Products.CMFCore.interfaces.ICatalogTool',
+    'Products.CMFCore.interfaces.IContentTypeRegistry',
+    'Products.CMFCore.interfaces.ISkinsTool',
+    'Products.CMFCore.interfaces.ITypesTool',
+    'Products.CMFCore.interfaces.IURLTool',
+    'Products.CMFCore.interfaces.IConfigurableWorkflowTool',
+    'Products.CMFCore.interfaces.IMembershipTool',
+    'Products.CMFCore.interfaces.IMetadataTool',
+    'Products.CMFCore.interfaces.IRegistrationTool',
+    ]
+
 def _log(msg):
     logger.info(msg)
     print msg
@@ -39,12 +57,21 @@
 def migrate_site(site):
     """ Migrate a single site
     """
+
     site_path = '/'.join(site.getPhysicalPath())
     _log(' - converting site at %s' % site_path)
     ps = site.portal_setup
 
-    # First we need to run items from the default CMF Site profile
+    # First we remove utility registrations that are no longer
+    # needed.
+    sm = getSiteManager(site)
+    for util in BAD_UTILITIES:
+        iface = resolve(util)
+        if sm.queryUtility(iface) is not None:
+            sm.unregisterUtility(provided=iface)
 
+    # Next we need to run items from the default CMF Site profile
+
     # Check if we have new-style action providers, if not we need to
     # run the action provider step from CMFDefault:default as well
     if not site.portal_actions.objectIds(['CMF Action Category']):



More information about the Checkins mailing list