Back to index

plone3  3.1.7
alphas.py
Go to the documentation of this file.
00001 import os
00002 from Acquisition import aq_base
00003 
00004 from Products.CMFCore.utils import getToolByName
00005 from Products.CMFCore.DirectoryView import createDirectoryView
00006 from Products.GenericSetup.tool import SetupTool
00007 
00008 from Products.CMFPlone.factory import _TOOL_ID as SETUP_TOOL_ID
00009 from Products.CMFPlone.migrations.migration_util import installOrReinstallProduct
00010 from Products.CMFPlone.migrations.v3_0.alphas import enableZope3Site
00011 from Products.CMFPlone.migrations.v3_0.alphas import registerToolsAsUtilities
00012 
00013 
00014 def two5_alpha1(portal):
00015     """2.1.2 -> 2.5-alpha1
00016     """
00017     out = []
00018 
00019     # Make the portal a Zope3 site
00020     enableZope3Site(portal, out)
00021 
00022     # register some tools as utilities
00023     registerToolsAsUtilities(portal, out)
00024 
00025     # Install portal_setup
00026     installPortalSetup(portal, out)
00027 
00028     # Install CMFPlacefulWorkflow
00029     installPlacefulWorkflow(portal, out)
00030 
00031     return out
00032 
00033 
00034 def alpha1_alpha2(portal):
00035     """2.5-alpha1 -> 2.5-alpha2
00036     """
00037     out = []
00038 
00039     # Make the portal a Zope3 site
00040     enableZope3Site(portal, out)
00041 
00042     # register some tools as utilities
00043     registerToolsAsUtilities(portal, out)
00044 
00045     # Install PlonePAS
00046     installPlonePAS(portal, out)
00047 
00048     # Install plone_deprecated skin
00049     installDeprecated(portal, out)
00050 
00051     return out
00052 
00053 
00054 def installPlacefulWorkflow(portal, out):
00055     """Quickinstalls CMFPlacefulWorkflow if not installed yet."""
00056     # CMFPlacefulWorkflow is not installed by e.g. tests
00057     if 'CMFPlacefulWorkflow' in portal.Control_Panel.Products.objectIds():
00058         installOrReinstallProduct(portal, 'CMFPlacefulWorkflow', out)
00059 
00060 
00061 def installPlonePAS(portal, out):
00062     """Quickinstalls PlonePAS if not installed yet."""
00063     NO_PLONEPAS = os.environ.get('SUPPRESS_PLONEPAS_INSTALLATION',None)=='YES'
00064     if not NO_PLONEPAS:
00065         installOrReinstallProduct(portal, 'PasswordResetTool', out)
00066         installOrReinstallProduct(portal, 'PlonePAS', out)
00067 
00068 
00069 def installDeprecated(portal, out):
00070     # register login skin
00071     st = getToolByName(portal, 'portal_skins', None)
00072     if st is None:
00073         return
00074     if not hasattr(aq_base(st), 'plone_deprecated'):
00075         createDirectoryView(st, 'Products.CMFPlone:skins/plone_deprecated')
00076         out.append('Added directory view for plone_deprecated')
00077 
00078     # add deprecated skin to default skins
00079     skins = ['Plone Default', 'Plone Tableless']
00080     selections = st._getSelections()
00081     for s in skins:
00082         if not selections.has_key(s):
00083            continue
00084         path = st.getSkinPath(s)
00085         path = [p.strip() for p in  path.split(',')]
00086         if not 'plone_deprecated' in path:
00087             if 'plone_3rdParty' in path:
00088                 path.insert(path.index('plone_3rdParty'), 'plone_deprecated')
00089             else:
00090                 path.append('plone_deprecated')
00091             st.addSkinSelection(s, ','.join(path))
00092             out.append('Added plone_deprecated to %s' % s)
00093 
00094 
00095 def installPortalSetup(portal, out):
00096     """Adds portal_setup if not installed yet."""
00097     if SETUP_TOOL_ID not in portal.objectIds():
00098         portal._setObject(SETUP_TOOL_ID, SetupTool(SETUP_TOOL_ID))
00099         out.append('Added setup_tool.')