Back to index

plone3  3.1.7
betas.py
Go to the documentation of this file.
00001 from zope.component import getUtilitiesFor
00002 from zope.interface import Interface
00003 
00004 from plone.portlets.interfaces import IPortletType
00005 
00006 from Products.CMFCore.utils import getToolByName
00007 from Products.CMFPlone.migrations.migration_util import loadMigrationProfile
00008 from Products.GenericSetup.browser.manage import ImportStepsView
00009 from Products.GenericSetup.browser.manage import ExportStepsView
00010 
00011 from Products.CMFPlone.setuphandlers import replace_local_role_manager
00012 
00013 def three0_beta1(portal):
00014     """3.0.6 -> 3.1-beta1
00015     """
00016     out = []
00017 
00018     loadMigrationProfile(portal, 'profile-Products.CMFPlone.migrations:3.0.6-3.1beta1')
00019 
00020     addBrowserLayer(portal, out)
00021     addCollectionAndStaticPortlets(portal, out)
00022     migratePortletTypeRegistrations(portal, out)
00023     removeDoubleGenericSetupSteps(portal, out)
00024     reinstallCMFPlacefulWorkflow(portal, out)
00025     replace_local_role_manager(portal, out)
00026 
00027     return out
00028 
00029 
00030 def addBrowserLayer(portal, out):
00031     qi=getToolByName(portal, "portal_quickinstaller")
00032     if not qi.isProductInstalled("plone.browserlayer"):
00033         qi.installProduct("plone.browserlayer", locked=True)
00034         out.append("Installed plone.browserlayer")
00035 
00036 def addCollectionAndStaticPortlets(portal, out):
00037     qi=getToolByName(portal, "portal_quickinstaller")
00038     if not qi.isProductInstalled("plone.portlet.static"):
00039         qi.installProduct("plone.portlet.static", locked=True)
00040         out.append("Installed plone.portlet.static")
00041     if not qi.isProductInstalled("plone.portlet.collection"):
00042         qi.installProduct("plone.portlet.collection", locked=True)
00043         out.append("Installed plone.portlet.collection")
00044 
00045 def migratePortletTypeRegistrations(portal, out):
00046     for name, portletType in getUtilitiesFor(IPortletType):
00047         if portletType.for_ is None:
00048             portletType.for_ = [Interface]
00049         elif type(portletType.for_) is not list:
00050             portletType.for_ = [portletType.for_]
00051     
00052     out.append("Migrated portlet types to support multiple " + \
00053       "portlet manager interfaces.")
00054 
00055 
00056 def removeDoubleGenericSetupSteps(portal, out):
00057     """Remove all GenericSetup steps that are registered both using
00058     zcml and in the persistent registry from the persistent registry.
00059     """
00060     st=getToolByName(portal, "portal_setup")
00061     view=ImportStepsView(st, None)
00062     steps=[step["id"] for step in view.doubleSteps()]
00063     if steps:
00064         for step in steps:
00065             st._import_registry.unregisterStep(step)
00066         st._p_changed=True
00067         out.append("Removed doubly registered GenericSetup import steps: %s" %
00068                 " ".join(steps))
00069 
00070     view=ExportStepsView(st, None)
00071     steps=[step["id"] for step in view.doubleSteps()]
00072     if steps:
00073         for step in steps:
00074             st._export_registry.unregisterStep(step)
00075         out.append("Removed doubly registered GenericSetup export steps: %s" %
00076                 " ".join(steps))
00077 
00078 def reinstallCMFPlacefulWorkflow(portal, out):
00079     qi = getToolByName(portal, 'portal_quickinstaller', None)
00080     if qi is not None:
00081         installed = qi.isProductInstalled('CMFPlacefulWorkflow')
00082         if installed:
00083             qi.reinstallProducts(['CMFPlacefulWorkflow'])
00084             out.append('Reinstalled CMFPlacefulWorkflow')