Back to index

plone3  3.1.7
Functions
CMFPlone.migrations.v3_0.betas Namespace Reference

Functions

def beta1_beta2
def beta2_beta3
def beta3_rc1
def migrateHistoryTab
def changeOrderOfActionProviders
def cleanupOldActions
def cleanDefaultCharset
def addAutoGroupToPAS
def removeS5Actions
def addCacheForKSSRegistry
def modifyKSSResources
def modifyKSSResourcesForDevelMode
def addContributorToCreationPermissions
def removeSharingAction
def addEditorToSecondaryEditorPermissions
def updateEditActionConditionForLocking
def addOnFormUnloadJS
def moveKupuAndCMFPWControlPanel
def updateLanguageControlPanel
def updateTopicTitle
def cleanupActionProviders
def hidePropertiesAction

Function Documentation

Definition at line 157 of file betas.py.

00157 
00158 def addAutoGroupToPAS(portal, out):
00159     from Products.PlonePAS.Extensions.Install import activatePluginInterfaces
00160     from StringIO import StringIO
00161 
00162     sout=StringIO()
00163 
00164     if not portal.acl_users.objectIds(['Automatic Group Plugin']):
00165         from Products.PlonePAS.plugins.autogroup import manage_addAutoGroup
00166         manage_addAutoGroup(portal.acl_users, 'auto_group',
00167                 'Automatic Group Provider',
00168                 'AuthenticatedUsers', "Logged-in users (Virtual Group)")
00169         activatePluginInterfaces(portal, "auto_group", sout)
00170         out.append("Added automatic group PAS plugin")

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 189 of file betas.py.

00189 
00190 def addCacheForKSSRegistry(portal, out):
00191     ram_cache_id = 'ResourceRegistryCache'
00192     reg = getToolByName(portal, 'portal_kss', None)
00193     if reg is not None and getattr(aq_base(reg), 'ZCacheable_setManagerId', None) is not None:
00194         reg.ZCacheable_setManagerId(ram_cache_id)
00195         reg.ZCacheable_setEnabled(1)
00196         out.append('Associated portal_kss with %s' % ram_cache_id)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 246 of file betas.py.

00246 
00247 def addContributorToCreationPermissions(portal, out):
00248     
00249     if 'Contributor' not in portal.valid_roles():
00250         portal._addRole('Contributor')
00251     if 'Contributor' not in portal.acl_users.portal_role_manager.listRoleIds():
00252         portal.acl_users.portal_role_manager.addRole('Contributor')
00253     
00254     for p in ['Add portal content', 'Add portal folders', 'ATContentTypes: Add Document',
00255                 'ATContentTypes: Add Event', 'ATContentTypes: Add Favorite',
00256                 'ATContentTypes: Add File', 'ATContentTypes: Add Folder', 
00257                 'ATContentTypes: Add Image', 'ATContentTypes: Add Large Plone Folder',
00258                 'ATContentTypes: Add Link', 'ATContentTypes: Add News Item', ]:
00259         roles = [r['name'] for r in portal.rolesOfPermission(p) if r['selected']]
00260         if 'Contributor' not in roles:
00261             roles.append('Contributor')
00262             portal.manage_permission(p, roles, bool(portal.acquiredRolesAreUsedBy(p)))

Here is the caller graph for this function:

Definition at line 273 of file betas.py.

00273 
00274 def addEditorToSecondaryEditorPermissions(portal, out):
00275     
00276     for p in ['Manage properties', 'Modify view template', 'Request review']:
00277         roles = [r['name'] for r in portal.rolesOfPermission(p) if r['selected']]
00278         if 'Editor' not in roles:
00279             roles.append('Editor')
00280             portal.manage_permission(p, roles, bool(portal.acquiredRolesAreUsedBy(p)))

Here is the caller graph for this function:

add the form unload JS to the js registry

Definition at line 299 of file betas.py.

00299 
00300 def addOnFormUnloadJS(portal, out):
00301     """
00302     add the form unload JS to the js registry
00303     """
00304     jsreg = getToolByName(portal, 'portal_javascripts', None)
00305     script = 'unlockOnFormUnload.js'
00306     if jsreg is not None:
00307         script_ids = jsreg.getResourceIds()
00308         # Failsafe: first make sure the stylesheet doesn't exist in the list
00309         if script not in script_ids:
00310             jsreg.registerScript(script,
00311                                  enabled = True,
00312                                  cookable = True)
00313             # put it at the bottom of the stack
00314             jsreg.moveResourceToBottom(script)
00315             out.append("Added " + script + " to portal_javascripts")

Here is the call graph for this function:

Here is the caller graph for this function:

3.0-beta1 -> 3.0-beta2

Definition at line 15 of file betas.py.

00015 
00016 def beta1_beta2(portal):
00017     """ 3.0-beta1 -> 3.0-beta2
00018     """
00019 
00020     out = []
00021 
00022     enableZope3Site(portal, out)
00023     registerToolsAsUtilities(portal, out)
00024 
00025     migrateHistoryTab(portal, out)
00026 
00027     changeOrderOfActionProviders(portal, out)
00028     updateEditActionConditionForLocking(portal, out)
00029     addOnFormUnloadJS(portal, out)
00030 
00031     # Add the action a second time, now to the correct action category
00032     addContentRulesAction(portal, out)
00033 
00034     cleanupOldActions(portal, out)
00035 
00036     cleanDefaultCharset(portal, out)
00037 
00038     loadMigrationProfile(portal, 'profile-Products.CMFPlone.migrations:3.0b1-3.0b2')
00039 
00040     addAutoGroupToPAS(portal, out)
00041 
00042     removeS5Actions(portal, out)
00043 
00044     addCacheForKSSRegistry(portal, out)
00045 
00046     modifyKSSResources(portal, out)
00047 
00048     addContributorToCreationPermissions(portal, out)
00049 
00050     cleanupActionProviders(portal, out)
00051 
00052     hidePropertiesAction(portal, out)
00053 
00054     return out
00055 

Here is the call graph for this function:

3.0-beta2 -> 3.0-beta3

Definition at line 56 of file betas.py.

00056 
00057 def beta2_beta3(portal):
00058     """ 3.0-beta2 -> 3.0-beta3
00059     """
00060 
00061     out = []
00062 
00063     enableZope3Site(portal, out)
00064     registerToolsAsUtilities(portal, out)
00065 
00066     loadMigrationProfile(portal, 'profile-Products.CMFPlone.migrations:3.0b2-3.0b3')
00067 
00068     removeSharingAction(portal, out)
00069     
00070     addEditorToSecondaryEditorPermissions(portal, out)
00071 
00072     return out
00073 

Here is the call graph for this function:

3.0-beta3 -> 3.0-rc1

Definition at line 74 of file betas.py.

00074 
00075 def beta3_rc1(portal):
00076     """ 3.0-beta3 -> 3.0-rc1
00077     """
00078 
00079     out = []
00080 
00081     enableZope3Site(portal, out)
00082     registerToolsAsUtilities(portal, out)
00083 
00084     loadMigrationProfile(portal, 'profile-Products.CMFPlone.migrations:3.0b3-3.0b4')
00085 
00086     moveKupuAndCMFPWControlPanel(portal, out)
00087 
00088     updateLanguageControlPanel(portal, out)
00089 
00090     updateTopicTitle(portal, out)
00091 
00092     modifyKSSResourcesForDevelMode(portal, out)
00093 
00094     return out
00095 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 106 of file betas.py.

00106 
00107 def changeOrderOfActionProviders(portal, out):
00108     portal_actions = getToolByName(portal, 'portal_actions', None)
00109     if portal_actions is not None:
00110         portal_actions.deleteActionProvider('portal_actions')
00111         portal_actions.addActionProvider('portal_actions')
00112         out.append('Changed the order of action providers.')

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 149 of file betas.py.

00149 
00150 def cleanDefaultCharset(portal, out):
00151     charset = portal.getProperty('default_charset', None)
00152     if charset is not None:
00153         if not charset.strip():
00154             portal.manage_delProperties(['default_charset'])
00155             out.append('Removed empty default_charset portal property')
00156 

Here is the caller graph for this function:

Remove no longer existing action proiders.

Definition at line 347 of file betas.py.

00347 
00348 def cleanupActionProviders(portal, out):
00349     """Remove no longer existing action proiders."""
00350     at = getToolByName(portal, "portal_actions")
00351     for provider in at.listActionProviders():
00352         candidate = getToolByName(portal, provider, None)
00353         if candidate is None or not IActionProvider.providedBy(candidate):
00354             at.deleteActionProvider(provider)
00355             out.append("%s is no longer an action provider" % provider)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 113 of file betas.py.

00113 
00114 def cleanupOldActions(portal, out):
00115     portal_actions = getToolByName(portal, 'portal_actions', None)
00116     if portal_actions is not None:
00117         # Remove some known unused actions from the object_tabs category and
00118         # remove the category completely if no actions are left
00119         object_tabs = getattr(portal_actions, 'object_tabs', None)
00120         if object_tabs is not None:
00121             if 'contentrules' in object_tabs.objectIds():
00122                 object_tabs._delObject('contentrules')
00123             if 'change_ownership' in object_tabs.objectIds():
00124                 object_tabs._delObject('change_ownership')
00125             if len(object_tabs.objectIds()) == 0:
00126                 del object_tabs
00127                 portal_actions._delObject('object_tabs')
00128                 out.append('Removed object_tabs action category.')
00129         object_ = getattr(portal_actions, 'object', None)
00130         if object_ is not None:
00131             if 'reply' in object_.objectIds():
00132                 object_._delObject('reply')
00133         user = getattr(portal_actions, 'user', None)
00134         if user is not None:
00135             if 'logged_in' in user.objectIds():
00136                 user._delObject('logged_in')
00137             if 'myworkspace' in user.objectIds():
00138                 user._delObject('myworkspace')
00139         global_ = getattr(portal_actions, 'global', None)
00140         if global_ is not None:
00141             if 'manage_members' in global_.objectIds():
00142                 global_._delObject('manage_members')
00143             if 'configPortal' in global_.objectIds():
00144                 global_._delObject('configPortal')
00145             if len(global_.objectIds()) == 0:
00146                 del global_
00147                 portal_actions._delObject('global')
00148                 out.append('Removed global action category.')

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 356 of file betas.py.

00356 
00357 def hidePropertiesAction(portal, out):
00358     tt = getToolByName(portal, 'portal_types', None)
00359     if not IActionProvider.providedBy(tt):
00360         return
00361     for ti in tt.listTypeInfo():
00362         actions = ti.listActions()
00363         index=[i for i in range(len(actions) )
00364                 if actions[i].category=="object" and 
00365                    actions[i].id=="metadata"]
00366         if index:
00367             ti.deleteActions(index)
00368             out.append("Removed properties action from type %s" % ti.id)
00369 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 96 of file betas.py.

00096 
00097 def migrateHistoryTab(portal, out):
00098     portal_actions = getToolByName(portal, 'portal_actions', None)
00099     if portal_actions is not None:
00100         objects = getattr(portal_actions, 'object', None)
00101         if objects is not None:
00102             if 'rss' in objects.objectIds():
00103                 objects.manage_renameObjects(['rss'], ['history'])
00104                 out.append('Migrated history action.')
00105 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 197 of file betas.py.

00197 
00198 def modifyKSSResources(portal, out):
00199     # make kukit.js conditonol and not load for anonymous
00200     reg = getToolByName(portal, 'portal_javascripts', None)
00201     if reg is not None:
00202         id = '++resource++kukit-src.js'
00203         entry = aq_base(reg).getResourcesDict().get(id, None)
00204         if entry:
00205             reg.updateScript(id, expression='not:here/@@plone_portal_state/anonymous', compression='safe')
00206             out.append('Updated kss javascript resource %s, to disable kss for anonymous.' % id)
00207     # register the new kss resources
00208     reg = getToolByName(portal, 'portal_kss', None)
00209     if reg is not None:
00210         new_resources = ['at_experimental.kss', 'plone_experimental.kss']
00211         for id in new_resources:
00212             entry = aq_base(reg).getResourcesDict().get(id, None)
00213             if not entry:
00214                 reg.registerKineticStylesheet(id, enabled=0)
00215                 out.append('Added kss resource %s, disabled by default.' % id)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 216 of file betas.py.

00216 
00217 def modifyKSSResourcesForDevelMode(portal, out):
00218     # separate kukit.js and kukit-src-js based on debug mode
00219     reg = getToolByName(portal, 'portal_javascripts', None)
00220     if reg is not None:
00221         id = '++resource++kukit-src.js'
00222         entry = aq_base(reg).getResourcesDict().get(id, None)
00223         if entry:
00224             pos = aq_base(reg).getResourcePosition(id)
00225             # delete kukit-src.js
00226             aq_base(reg).unregisterResource(id)
00227             # add the new ones
00228             id1 = '++resource++kukit.js'
00229             if aq_base(reg).getResourcesDict().get(id1, None):
00230                 aq_base(reg).unregisterResource(id1)
00231             aq_base(reg).registerScript(id1,
00232                     expression="python: not here.restrictedTraverse('@@plone_portal_state').anonymous() and here.restrictedTraverse('@@kss_devel_mode').isoff()",
00233                     inline=False, enabled=True,
00234                     cookable=True, compression='none', cacheable=True)
00235             id2 = '++resource++kukit-devel.js'
00236             if aq_base(reg).getResourcesDict().get(id2, None):
00237                 aq_base(reg).unregisterResource(id2)
00238             aq_base(reg).registerScript(id2,
00239                     expression="python: not here.restrictedTraverse('@@plone_portal_state').anonymous() and here.restrictedTraverse('@@kss_devel_mode').ison()",
00240                     inline=False, enabled=True,
00241                     cookable=True, compression='none', cacheable=True)
00242             # move them to where the old one has been
00243             aq_base(reg).moveResource(id1, pos)
00244             aq_base(reg).moveResource(id2, pos + 1)
00245             out.append('Updated kss javascript resources, to enable the use of production and development versions.')

Here is the call graph for this function:

Here is the caller graph for this function:

Move Kupu control panel to the Plone section and the CMFPW control panel
to the add-on section if it is installed.

Definition at line 316 of file betas.py.

00316 
00317 def moveKupuAndCMFPWControlPanel(portal, out):
00318     """
00319     Move Kupu control panel to the Plone section and the CMFPW control panel
00320     to the add-on section if it is installed.
00321     """
00322     cp = getToolByName(portal, 'portal_controlpanel', None)
00323     if cp is not None:
00324         kupu = cp.getActionObject('Products/kupu')
00325         if kupu is not None:
00326             kupu.category = 'Plone'
00327         cmfpw = cp.getActionObject('Plone/placefulworkflow')
00328         if cmfpw is not None:
00329             cmfpw.category = 'Products'

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 171 of file betas.py.

00171 
00172 def removeS5Actions(portal, out):
00173     portalTypes = getToolByName(portal, 'portal_types', None)
00174     if portalTypes is not None:
00175         document = portalTypes.restrictedTraverse('Document', None)
00176         if document:
00177             ids = [x.getId() for x in document.listActions()]
00178             if 's5_presentation' in ids:
00179                 index = ids.index('s5_presentation')
00180                 document.deleteActions([index])
00181                 out.append("Removed 's5_presentation' action from actions tool.")
00182 
00183     iconsTool = queryUtility(IActionIconsTool)
00184     if iconsTool is not None:
00185         ids = [x.getActionId() for x in iconsTool.listActionIcons()]
00186         if 's5_presentation' in ids:
00187             iconsTool.removeActionIcon('plone','s5_presentation')
00188             out.append("Removed 's5_presentation' icon from actionicons tool.")

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 263 of file betas.py.

00263 
00264 def removeSharingAction(portal, out):
00265     portal_types = getToolByName(portal, 'portal_types', None)
00266     if portal_types is not None:
00267         for fti in portal_types.objectValues():
00268             action_ids = [a.id for a in fti.listActions()]
00269             if 'local_roles' in action_ids:
00270                 fti.deleteActions([action_ids.index('local_roles')])
00271                 
00272     out.append('Removed explicit references to sharing action')
    

Here is the call graph for this function:

Here is the caller graph for this function:

Condition on edit views for Document, Event, File, Folder, Image, 
Large_Plone_Folder, Link, Topic has been added to not display the Edit
tab if an item is locked

Definition at line 281 of file betas.py.

00281 
00282 def updateEditActionConditionForLocking(portal, out):
00283     """
00284     Condition on edit views for Document, Event, File, Folder, Image, 
00285     Large_Plone_Folder, Link, Topic has been added to not display the Edit
00286     tab if an item is locked
00287     """
00288     portal_types = getToolByName(portal, 'portal_types', None)
00289     lockable_types = ['Document', 'Event', 'Favorite', 'File', 'Folder',
00290                       'Image', 'Large Plone Folder', 'Link',
00291                       'News Item', 'Topic']
00292     if portal_types is not None:
00293         for contentType in lockable_types:
00294             fti = portal_types.getTypeInfo(contentType)
00295             if fti:
00296                 for action in fti.listActions():
00297                     if action.getId() == 'edit' and not action.condition:
00298                         action.condition = Expression("not:object/@@plone_lock_info/is_locked_for_current_user|python:True")

Here is the call graph for this function:

Here is the caller graph for this function:

Use the new configlet for the language control panel

Definition at line 330 of file betas.py.

00330 
00331 def updateLanguageControlPanel(portal, out):
00332     """Use the new configlet for the language control panel"""
00333     cp = getToolByName(portal, 'portal_controlpanel', None)
00334     if cp is not None:
00335         lang = cp.getActionObject('Plone/PloneLanguageTool')
00336         if lang is not None:
00337             lang.action = Expression('string:${portal_url}/@@language-controlpanel')

Here is the call graph for this function:

Here is the caller graph for this function:

Update the title of the topic type.

Definition at line 338 of file betas.py.

00338 
00339 def updateTopicTitle(portal, out):
00340     """Update the title of the topic type."""
00341     tt = getToolByName(portal, 'portal_types', None)
00342     if tt is not None:
00343         topic = tt.get('Topic')
00344         if topic is not None:
00345             topic.title = 'Collection'
00346 

Here is the call graph for this function:

Here is the caller graph for this function: