[Checkins] SVN: Products.GenericSetup/branches/1.6/ Option: use only import / export steps explicitly names by the current profile.
Tres Seaver
tseaver at palladion.com
Wed Feb 29 01:51:07 UTC 2012
Log message for revision 124484:
Option: use only import / export steps explicitly names by the current profile.
If this option is set, the setup tool ignores any steps which might be
globally registered: it uses only those named in the profile's
'import_steps.xml' / 'export_steps.xml' files.
This is particularly useful for configuring sites with baseline profiles,
where arbitrary add-on steps are not only useless, but potentially damaging.
Changed:
U Products.GenericSetup/branches/1.6/Products/GenericSetup/interfaces.py
U Products.GenericSetup/branches/1.6/Products/GenericSetup/tests/test_tool.py
U Products.GenericSetup/branches/1.6/Products/GenericSetup/tool.py
U Products.GenericSetup/branches/1.6/Products/GenericSetup/www/sutProperties.zpt
U Products.GenericSetup/branches/1.6/docs/CHANGES.rst
-=-
Modified: Products.GenericSetup/branches/1.6/Products/GenericSetup/interfaces.py
===================================================================
--- Products.GenericSetup/branches/1.6/Products/GenericSetup/interfaces.py 2012-02-28 23:39:59 UTC (rev 124483)
+++ Products.GenericSetup/branches/1.6/Products/GenericSetup/interfaces.py 2012-02-29 01:51:06 UTC (rev 124484)
@@ -490,6 +490,16 @@
""" Specify the base profile for this configuration.
"""
+ def getExcludeGlobalSteps():
+ """ Does this instance of the tool ignore globally-registered steps?
+ """
+
+ def setExcludeGlobalSteps(value):
+ """ Specify whether to ignore globally-registered steps.
+
+ 'value' must be a boolean.
+ """
+
def applyContext( context, encoding=None ):
""" Update the tool from the supplied context, without modifying its
Modified: Products.GenericSetup/branches/1.6/Products/GenericSetup/tests/test_tool.py
===================================================================
--- Products.GenericSetup/branches/1.6/Products/GenericSetup/tests/test_tool.py 2012-02-28 23:39:59 UTC (rev 124483)
+++ Products.GenericSetup/branches/1.6/Products/GenericSetup/tests/test_tool.py 2012-02-29 01:51:06 UTC (rev 124484)
@@ -408,6 +408,7 @@
PROFILE_ID = 'snapshot-testing'
site = self._makeSite( TITLE )
tool = self._makeOne('setup_tool').__of__( site )
+ tool._exclude_global_steps = True
registry = tool.getImportStepRegistry()
registry.registerStep( 'dependable', '1'
@@ -419,17 +420,17 @@
result = tool.runAllImportStepsFromProfile(PROFILE_ID)
- self.assertEqual( len(result['steps']), 6 )
+ self.assertEqual( len(result['steps']), 3 )
- self.assertEqual( result['steps'][3], 'purging' )
+ self.assertEqual( result['steps'][0], 'purging' )
self.assertEqual( result[ 'messages' ][ 'purging' ]
, 'Purged' )
- self.assertEqual( result['steps'][4], 'dependable' )
+ self.assertEqual( result['steps'][1], 'dependable' )
self.assertEqual( result[ 'messages' ][ 'dependable' ]
, 'Underscored title' )
- self.assertEqual( result['steps'][5], 'dependent' )
+ self.assertEqual( result['steps'][2], 'dependent' )
self.assertEqual( result[ 'messages' ][ 'dependent' ]
, 'Uppercased title' )
@@ -465,6 +466,7 @@
site = self._makeSite()
tool = self._makeOne('setup_tool').__of__( site )
+ tool._exclude_global_steps = True
registry = tool.getImportStepRegistry()
registry.registerStep( 'dependable', '1'
@@ -477,20 +479,21 @@
result = tool.runAllImportStepsFromProfile('snapshot-dummy',
purge_old=True )
- self.assertEqual( len(result['steps']), 6 )
+ self.assertEqual( len(result['steps']), 3 )
- self.assertEqual( result['steps'][3], 'purging' )
+ self.assertEqual( result['steps'][0], 'purging' )
self.assertEqual( result[ 'messages' ][ 'purging' ]
, 'Purged' )
- self.assertEqual( result['steps'][4], 'dependable' )
- self.assertEqual( result['steps'][5], 'dependent' )
+ self.assertEqual( result['steps'][1], 'dependable' )
+ self.assertEqual( result['steps'][2], 'dependent' )
self.failUnless( site.purged )
def test_runAllImportStepsFromProfile_sorted_skip_purge(self):
site = self._makeSite()
tool = self._makeOne('setup_tool').__of__( site )
+ tool._exclude_global_steps = True
registry = tool.getImportStepRegistry()
registry.registerStep( 'dependable', '1'
@@ -503,14 +506,14 @@
result = tool.runAllImportStepsFromProfile('snapshot-dummy',
purge_old=False )
- self.assertEqual( len(result['steps']), 6 )
+ self.assertEqual( len(result['steps']), 3 )
- self.assertEqual( result['steps'][3], 'purging' )
+ self.assertEqual( result['steps'][0], 'purging' )
self.assertEqual( result[ 'messages' ][ 'purging' ]
, 'Unpurged' )
- self.assertEqual( result['steps'][4], 'dependable' )
- self.assertEqual( result['steps'][5], 'dependent' )
+ self.assertEqual( result['steps'][1], 'dependable' )
+ self.assertEqual( result['steps'][2], 'dependent' )
self.failIf( site.purged )
def test_runAllImportStepsFromProfile_without_depends(self):
Modified: Products.GenericSetup/branches/1.6/Products/GenericSetup/tool.py
===================================================================
--- Products.GenericSetup/branches/1.6/Products/GenericSetup/tool.py 2012-02-28 23:39:59 UTC (rev 124483)
+++ Products.GenericSetup/branches/1.6/Products/GenericSetup/tool.py 2012-02-29 01:51:06 UTC (rev 124484)
@@ -165,6 +165,8 @@
_profile_upgrade_versions = {}
+ _exclude_global_steps = False
+
security = ClassSecurityInfo()
def __init__(self, id):
@@ -195,6 +197,18 @@
self._baseline_context_id = context_id
self.applyContextById(context_id, encoding)
+ security.declareProtected(ManagePortal, 'getExcludeGlobalSteps')
+ def getExcludeGlobalSteps(self):
+ """ See ISetupTool.
+ """
+ return self._exclude_global_steps
+
+ security.declareProtected(ManagePortal, 'setExcludeGlobalSteps')
+ def setExcludeGlobalSteps(self, value):
+ """ See ISetupTool.
+ """
+ self._exclude_global_steps = value
+
security.declareProtected(ManagePortal, 'applyContextById')
def applyContextById(self, context_id, encoding=None):
context = self._getImportContext(context_id)
@@ -217,51 +231,62 @@
"""
return self._export_registry
- security.declareProtected(ManagePortal, 'getExportStep')
- def getExportStep(self, step, default=None):
- """Simple wrapper to query both the global and local step registry."""
- res=_export_step_registry.getStep(step, default)
- if res is not default:
- return res
- return self._export_registry.getStep(step, default)
-
- security.declareProtected(ManagePortal, 'listExportSteps')
- def listExportSteps(self):
- steps = _export_step_registry.listSteps() + \
- self._export_registry.listSteps()
- return tuple(set(steps))
-
security.declareProtected(ManagePortal, 'getImportStep')
def getImportStep(self, step, default=None):
"""Simple wrapper to query both the global and local step registry."""
- res=_import_step_registry.getStep(step, default)
- if res is not default:
+ res = self._import_registry.getStep(step, self)
+ if res is self and not self._exclude_global_steps:
+ res = _import_step_registry.getStep(step, self)
+ if res is not self:
return res
- return self._import_registry.getStep(step, default)
+ return default
security.declareProtected(ManagePortal, 'getSortedImportSteps')
def getSortedImportSteps(self):
- steps = _import_step_registry.listSteps() + \
- self._import_registry.listSteps()
- step_infos = [ self.getImportStepMetadata(step)
- for step in set(steps) ]
+ if self._exclude_global_steps:
+ steps = set()
+ else:
+ steps = set(_import_step_registry.listSteps())
+ steps.update(set(self._import_registry.listSteps()))
+ step_infos = [self.getImportStepMetadata(step) for step in steps]
return tuple(_computeTopologicalSort(step_infos))
security.declareProtected(ManagePortal, 'getImportStepMetadata')
def getImportStepMetadata(self, step, default=None):
"""Simple wrapper to query both the global and local step registry."""
- res=self._import_registry.getStepMetadata(step, default)
- if res is not default:
+ res = self._import_registry.getStepMetadata(step, self)
+ if res is self and not self._exclude_global_steps:
+ res = _import_step_registry.getStepMetadata(step, default)
+ if res is not self:
return res
- return _import_step_registry.getStepMetadata(step, default)
+ return default
+ security.declareProtected(ManagePortal, 'getExportStep')
+ def getExportStep(self, step, default=None):
+ """Simple wrapper to query both the global and local step registry."""
+ res = self._export_registry.getStep(step, self)
+ if res is self and not self._exclude_global_steps:
+ res = _export_step_registry.getStep(step, self)
+ if res is not self:
+ return res
+ return default
+
+ security.declareProtected(ManagePortal, 'listExportSteps')
+ def listExportSteps(self):
+ steps = set(self._export_registry.listSteps())
+ if not self._exclude_global_steps:
+ steps.update(set(_export_step_registry.listSteps()))
+ return tuple(steps)
+
security.declareProtected(ManagePortal, 'getExportStepMetadata')
def getExportStepMetadata(self, step, default=None):
"""Simple wrapper to query both the global and local step registry."""
- res=self._export_registry.getStepMetadata(step, default)
- if res is not default:
+ res = self._export_registry.getStepMetadata(step, self)
+ if res is self and not self._exclude_global_steps:
+ res = _export_step_registry.getStepMetadata(step, default)
+ if res is not self:
return res
- return _export_step_registry.getStepMetadata(step, default)
+ return default
security.declareProtected(ManagePortal, 'getToolsetRegistry')
def getToolsetRegistry(self):
@@ -472,13 +497,17 @@
manage_tool = PageTemplateFile('sutProperties', _wwwdir)
security.declareProtected(ManagePortal, 'manage_updateToolProperties')
- def manage_updateToolProperties(self, context_id, RESPONSE):
+ def manage_updateToolProperties(self, context_id,
+ exclude_global_steps=False,
+ RESPONSE=None):
""" Update the tool's settings.
"""
+ self.setExcludeGlobalSteps(exclude_global_steps)
self.setBaselineContext(context_id)
- RESPONSE.redirect('%s/manage_tool?manage_tabs_message=%s'
- % (self.absolute_url(), 'Properties+updated.'))
+ if RESPONSE is not None:
+ RESPONSE.redirect('%s/manage_tool?manage_tabs_message=%s'
+ % (self.absolute_url(), 'Properties+updated.'))
security.declareProtected(ManagePortal, 'manage_importSteps')
manage_importSteps = PageTemplateFile('sutImportSteps', _wwwdir)
@@ -949,7 +978,7 @@
for step_info in info_list:
id = step_info['id']
- version = step_info['version']
+ version = step_info.get('version')
handler = step_info['handler']
dependencies = tuple(step_info.get('dependencies', ()))
title = step_info.get('title', id)
Modified: Products.GenericSetup/branches/1.6/Products/GenericSetup/www/sutProperties.zpt
===================================================================
--- Products.GenericSetup/branches/1.6/Products/GenericSetup/www/sutProperties.zpt 2012-02-28 23:39:59 UTC (rev 124483)
+++ Products.GenericSetup/branches/1.6/Products/GenericSetup/www/sutProperties.zpt 2012-02-29 01:51:06 UTC (rev 124484)
@@ -52,14 +52,25 @@
<div id="overwrite"
tal:attributes="style overwrite_style">
- <select name="context_id">
- <option value="context-CONTEXT_ID"
- tal:repeat="context_info bases"
- tal:attributes="selected python:context_id == context_info['id'];
+ <fieldset id="context_id_fs">
+ <label>Context ID</label>
+ <select name="context_id">
+ <option value="context-CONTEXT_ID"
+ tal:repeat="context_info bases"
+ tal:attributes="selected python:context_id == context_info['id'];
value context_info/id"
- tal:content="context_info/title"
- >CONTEXT_TITLE</option>
- </select>
+ tal:content="context_info/title"
+ >CONTEXT_TITLE</option>
+ </select>
+ </fieldset>
+ <fieldset id="exclude_global_steps_fs">
+ <label>Exclude global steps?</label>
+ <input type="checkbox" name="exclude_global_steps"
+ tal:attributes="checked context/getExcludeGlobalSteps"
+ />
+ <p><em>If checked, only steps explicitly registered by the profile will
+ be available.</em></p>
+ </fieldset>
<input class="form-element" type="submit"
name="manage_updateToolProperties:method"
value="Update Base Profile" />
Modified: Products.GenericSetup/branches/1.6/docs/CHANGES.rst
===================================================================
--- Products.GenericSetup/branches/1.6/docs/CHANGES.rst 2012-02-28 23:39:59 UTC (rev 124483)
+++ Products.GenericSetup/branches/1.6/docs/CHANGES.rst 2012-02-29 01:51:06 UTC (rev 124484)
@@ -4,7 +4,13 @@
1.6.6 (unreleased)
------------------
+- Restored the ability to make the setup tool use only import / export
+ steps explicitly called out by the current profile, ignoring any which
+ might be globally registered. This is particularly useful for configuring
+ sites with baseline profiles, where arbitrary add-on steps are not only
+ useless, but potentially damaging.
+
1.6.5 (2012-01-27)
------------------
More information about the checkins
mailing list