Back to index

plone3  3.1.7
Functions | Variables
CMFPlone.migrations.v2_5.betas Namespace Reference

Functions

def alpha2_beta1
def beta1_beta2
def addDragDropReorderJS
def addGetEventTypeIndex
def fixHomeAction
def removeBogusSkin
def addPloneSkinLayers
def installPortalSetup
def simplifyActions
def migrateCSSRegExpression

Variables

list action_replacements

Function Documentation

Add dragdropreorder.js to ResourceRegistries.

Definition at line 97 of file betas.py.

00097 
00098 def addDragDropReorderJS(portal, out):
00099     """Add dragdropreorder.js to ResourceRegistries.
00100     """
00101     jsreg = getToolByName(portal, 'portal_javascripts', None)
00102     script = 'dragdropreorder.js'
00103     if jsreg is not None:
00104         script_ids = jsreg.getResourceIds()
00105         # Failsafe: first make sure the stylesheet doesn't exist in the list
00106         if script not in script_ids:
00107             jsreg.registerScript(script)
00108             try:
00109                 jsreg.moveResourceAfter(script, 'dropdown.js')
00110             except ValueError:
00111                 # put it at the bottom of the stack
00112                 jsreg.moveResourceToBottom(script)
00113             out.append("Added " + script + " to portal_javascipt")
00114 

Here is the call graph for this function:

Here is the caller graph for this function:

Adds the getEventType KeywordIndex.

Definition at line 115 of file betas.py.

00115 
00116 def addGetEventTypeIndex(portal, out):
00117     """Adds the getEventType KeywordIndex."""
00118     catalog = getToolByName(portal, 'portal_catalog', None)
00119     if catalog is not None:
00120         if 'getEventType' in catalog.indexes():
00121             index = [i for i in catalog.index_objects() if
00122                                          i.getId() == 'getEventType']
00123             indextype = index.__class__.__name__
00124             if indextype == 'KeywordIndex':
00125                 return 0
00126             catalog.delIndex('getEventType')
00127             out.append("Deleted %s 'getEventType' from portal_catalog." %
00128                        indextype)
00129 
00130         catalog.addIndex('getEventType', 'KeywordIndex')
00131         out.append("Added KeywordIndex 'getEventType' to portal_catalog.")
00132         return 1 # Ask for reindexing
00133     return 0
00134 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 168 of file betas.py.

00168 
00169 def addPloneSkinLayers(portal, out):
00170     st = getToolByName(portal, 'portal_skins', None)
00171     if st is None:
00172         out.append('No portal_skins tool')
00173         return
00174 
00175     for skin in st._getSelections().keys():
00176         path = st.getSkinPath(skin)
00177         path = [p.strip() for p in path.split(',')]
00178         if not 'plone_deprecated' in path:
00179             path.append('plone_deprecated')
00180             st.addSkinSelection(skin, ','.join(path))
00181             out.append('Added plone_deprecated to %s' % skin)
00182 

Here is the call graph for this function:

Here is the caller graph for this function:

2.5-alpha2 -> 2.5-beta1

Definition at line 20 of file betas.py.

00020 
00021 def alpha2_beta1(portal):
00022     """2.5-alpha2 -> 2.5-beta1
00023     """
00024     out = []
00025 
00026     # Make the portal a Zope3 site
00027     enableZope3Site(portal, out)
00028 
00029     # register some tools as utilities
00030     registerToolsAsUtilities(portal, out)
00031 
00032     # Add dragdropreorder.js to ResourceRegistries.
00033     addDragDropReorderJS(portal, out)
00034 
00035     # Add getEventTypes KeywordIndex to portal_catalog
00036     addGetEventTypeIndex(portal, out)
00037 
00038     # We need to migrate all existing actions to new-style actions first
00039     migrateOldActions(portal, out)
00040     # Fix 'home' portal action
00041     fixHomeAction(portal, out)
00042 
00043     # Fixup the navtree properties (this was already done in 2.1.3, but may
00044     # need to be done again for those migrating from alphas)
00045     normalizeNavtreeProperties(portal, out)
00046 
00047     return out
00048 

Here is the call graph for this function:

2.5-beta1 - > 2.5-beta2

Definition at line 49 of file betas.py.

00049 
00050 def beta1_beta2(portal):
00051     """2.5-beta1 - > 2.5-beta2
00052     """
00053     out = []
00054 
00055     # Make the portal a Zope3 site
00056     enableZope3Site(portal, out)
00057 
00058     # register some tools as utilities
00059     registerToolsAsUtilities(portal, out)
00060 
00061     # The migration done during the alpha screwed things up, so we do it again
00062     # and fix the mistake while we're at it
00063     installDeprecated(portal, out)
00064     removeBogusSkin(portal, out)
00065 
00066     # add a property indicating if this is a big or small site, so the UI can
00067     # change depending on it
00068     propTool = getToolByName(portal, 'portal_properties', None)
00069     propSheet = getattr(propTool, 'site_properties', None)
00070     if not propSheet.hasProperty('large_site'):
00071         propSheet.manage_addProperty('large_site', 0, 'boolean')
00072         out.append("Added 'large_site' property to site_properties.")
00073 
00074     # Remove vcXMLRPC.js from ResourceRegistries (this was already done in
00075     # 2.1.3, but may need to be done again for those migrating from alphas)
00076     removeVcXMLRPC(portal, out)
00077 
00078     # add icons for copy, cut, paste and delete
00079     addActionDropDownMenuIcons(portal, out)
00080 
00081     # add any appropriate plone skin layers to custom skins
00082     addPloneSkinLayers(portal, out)
00083 
00084     # Install portal_setup
00085     installPortalSetup(portal, out)
00086 
00087     # We need to migrate all existing actions to new-style actions first
00088     migrateOldActions(portal, out)
00089     # Simplify actions using the @@plone view
00090     simplifyActions(portal, out)
00091 
00092     # Use the @@plone view for the RTL.css expression entry
00093     migrateCSSRegExpression(portal, out)
00094 
00095     return out
00096 

Here is the call graph for this function:

def CMFPlone.migrations.v2_5.betas.fixHomeAction (   portal,
  out 
)
Make the 'home' action use the @@plone view to get a properly rooted
navtree.

Definition at line 135 of file betas.py.

00135 
00136 def fixHomeAction(portal, out):
00137     """Make the 'home' action use the @@plone view to get a properly rooted
00138     navtree.
00139     """
00140     home = Action('index_html',
00141         title='Home',
00142         i18n_domain='plone',
00143         url_expr='string:${here/@@plone/navigationRootUrl}',
00144         available_expr='',
00145         permissions=(View,),
00146         visible=True)
00147 
00148     actionsTool = getToolByName(portal, 'portal_actions', None)
00149     if actionsTool is not None:
00150         category = actionsTool.portal_tabs
00151         for action in category.objectIds():
00152             # if action exists, remove and re-add
00153             if action == 'index_html':
00154                 category._delObject('index_html')
00155                 break
00156 
00157         category['index_html'] = home
00158         category.moveObjectsToTop(('index_html',))
00159         out.append("Added/modified home/index_html portal_tabs action.")
00160 

Here is the call graph for this function:

Here is the caller graph for this function:

Adds portal_setup if not installed yet.

Definition at line 183 of file betas.py.

00183 
00184 def installPortalSetup(portal, out):
00185     """Adds portal_setup if not installed yet."""
00186     if SETUP_TOOL_ID not in portal.objectIds():
00187         portal._setObject(SETUP_TOOL_ID, SetupTool(SETUP_TOOL_ID))
00188         out.append('Added setup_tool.')
00189 
00190 
00191 # A set of regexes and substitution strings for cleaning up the current
00192 # actions, in particular to make optimal use of the methods provided by
# @@plone and remove deprecation warnings.

Here is the caller graph for this function:

Changes calls to the isRightToLeft script to use the view, also
   replaces the use of restrictedTraverse with a more compact path
   expression.

Definition at line 250 of file betas.py.

00250 
00251 def migrateCSSRegExpression(portal, out):
00252     """Changes calls to the isRightToLeft script to use the view, also
00253        replaces the use of restrictedTraverse with a more compact path
00254        expression."""
00255     css_reg = getToolByName(portal, 'portal_css', None)
00256     if css_reg is not None:
00257         resource = css_reg.getResource('RTL.css')
00258         # The None that comes out of RR is apparently acquisition wrapped,
00259         # nasty.
00260         if aq_base(resource) is not None:
00261             css_expr = resource.getExpression()
00262             new_expr = 'object/@@plone/isRightToLeft'
00263             if "object.isRightToLeft" in css_expr or \
00264                "object.restrictedTraverse('@@plone')" in css_expr:
00265                 resource.setExpression(new_expr)
00266                 css_reg.cookResources()
00267                 out.append("Fixed RTL.css expression to use the @@plone view")

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 161 of file betas.py.

00161 
00162 def removeBogusSkin(portal, out):
00163     skins = getToolByName(portal, 'portal_skins', None)
00164     if skins is not None:
00165         if skins._getSelections().has_key('cmf_legacy'):
00166             skins.manage_skinLayers(('cmf_legacy',), del_skin=True)
00167             out.append("Deleted incorrectly added 'cmf_legacy' skin")

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 218 of file betas.py.

00218 
00219 def simplifyActions(portal, out):
00220     from Products.CMFCore.ActionInformation import ActionCategory
00221     tool = getToolByName(portal, 'portal_actions', None)
00222     if tool is not None:
00223         categories = [obj for obj in tool.objectItems()
00224                                   if isinstance(obj[1], ActionCategory)]
00225         if not categories:
00226             return
00227         actions = tool.listActions()
00228         # iterate through the actions and for each action check if it
00229         # matches any of the patterns we want to replace
00230         for action in actions:
00231             action_id = '%s/%s'%(action.getInfoData()[0]['category'], action.id)
00232             cur_expr = action.getProperty('url_expr')
00233             cur_condition = action.getProperty('available_expr')
00234             for regex, replacement in action_replacements:
00235                 new_expr = regex.sub(replacement, cur_expr)
00236                 new_condition = regex.sub(replacement, cur_condition)
00237                 if new_expr != cur_expr:
00238                     action._updateProperty('url_expr', new_expr)
00239                     out.append(
00240                     'Changed url expression on action %s from: \n%s\nto:\n%s'%(
00241                                                 action_id, cur_expr, new_expr))
00242                 if new_condition != cur_condition:
00243                     action._updateProperty('available_expr', new_condition)
00244                     out.append(
00245                     'Changed condition on action %s from: \n"%s"\nto:\n"%s"'%(
00246                                      action_id, cur_condition, new_condition))
00247                 cur_expr = new_expr
00248                 cur_condition = new_condition
00249 

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
00001 [
00002 # Remove leading space from string and python expressions, it is annoying
00003 (re.compile(r"^string: "),
00004  r"string:"),
00005 (re.compile(r"^python: "),
00006  r"python:"),
00007 (re.compile(r"portal\.portal_membership\.checkPermission"),
00008  r"checkPermission"),
00009 (re.compile(r"^python:\(\(object\.isDefaultPageInFolder\(\) and object.getParentNode\(\)\.absolute_url\(\)\) or folder_url\)\+(?:\"|')/(.+)(?:\"|')$"),
00010  r"string:${globals_view/getCurrentFolderUrl}/\1"),
00011 (re.compile(r"python:(?:\"|')%s/(.+)(?:\"|')%\(\(object\.isDefaultPageInFolder\(\) or not object\.is_folderish\(\)\) and object\.getParentNode\(\)\.absolute_url\(\) or object_url\)$"),
00012  r"string:${globals_view/getCurrentFolderUrl}/\1"),
00013 (re.compile(r"^python:(?:\"|')%s/(.+)(?:\"|')%\(object\.isDefaultPageInFolder\(\) and object.getParentNode\(\)\.absolute_url\(\) or object_url\)$"),
00014  r"string:${globals_view/getCurrentObjectUrl}/\1"),
00015 (re.compile(r"object is not portal and not \(object\.isDefaultPageInFolder\(\) and object\.getParentNode\(\) is portal\)"),
00016  r"not globals_view.isPortalOrPortalDefaultPage()"),
00017 (re.compile(r"object\.aq_inner\.getParentNode\(\)"),
00018  r"globals_view.getParentObject()"),
00019 (re.compile("here/@@plone"),
00020  r"globals_view"),
00021 (re.compile(r"^python:portal\.portal_membership\.getHomeUrl\(\)\+(?:\"|')/(.+)(?:\"|')$"),
00022  r"string:${portal/portal_membership/getHomeUrl}/\1"),
00023 ]

Definition at line 193 of file betas.py.