[Checkins] SVN: CMF/branches/2.1/ Merge CMF/trunk/DCWorkflow r80702
Ross Patterson
me at rpatterson.net
Mon Oct 8 03:41:41 EDT 2007
Log message for revision 80705:
Merge CMF/trunk/DCWorkflow r80702
DCWorkflow.exportimport: Scripts with invalid types imported
after scripts with valid types will no longer place the valid
script twice. Scripts can also now be specified with meta_types
other than the hard-coded meta_types.
Changed:
U CMF/branches/2.1/CHANGES.txt
U CMF/branches/2.1/DCWorkflow/exportimport.py
U CMF/branches/2.1/DCWorkflow/tests/test_exportimport.py
-=-
Modified: CMF/branches/2.1/CHANGES.txt
===================================================================
--- CMF/branches/2.1/CHANGES.txt 2007-10-08 07:29:25 UTC (rev 80704)
+++ CMF/branches/2.1/CHANGES.txt 2007-10-08 07:41:41 UTC (rev 80705)
@@ -2,6 +2,11 @@
Bug Fixes
+ - DCWorkflow.exportimport: Scripts with invalid types imported
+ after scripts with valid types will no longer place the valid
+ script twice. Scripts can also now be specified with meta_types
+ other than the hard-coded meta_types.
+
- CMFDefault.utils: The email validation would reject addresses where
the domain part started with a single letter element.
(http://www.zope.org/Collectors/CMF/495)
Modified: CMF/branches/2.1/DCWorkflow/exportimport.py
===================================================================
--- CMF/branches/2.1/DCWorkflow/exportimport.py 2007-10-08 07:29:25 UTC (rev 80704)
+++ CMF/branches/2.1/DCWorkflow/exportimport.py 2007-10-08 07:41:41 UTC (rev 80705)
@@ -1156,6 +1156,18 @@
elif meta_type == DTMLMethod.meta_type:
script = DTMLMethod( file, __name__=id )
+ else:
+ for mt in workflow.scripts.filtered_meta_types():
+ if mt['name']==meta_type:
+ if hasattr(mt['instance'], 'write'):
+ script = mt['instance'](id)
+ script.write(file)
+ else:
+ script = mt['instance'](file, __name__=id)
+ break
+ else:
+ raise ValueError, 'Invalid type: %s' % meta_type
+
if workflow.scripts.has_key(id):
workflow.scripts._delObject(id)
workflow.scripts._setObject( id, script )
Modified: CMF/branches/2.1/DCWorkflow/tests/test_exportimport.py
===================================================================
--- CMF/branches/2.1/DCWorkflow/tests/test_exportimport.py 2007-10-08 07:29:25 UTC (rev 80704)
+++ CMF/branches/2.1/DCWorkflow/tests/test_exportimport.py 2007-10-08 07:41:41 UTC (rev 80705)
@@ -2423,7 +2423,53 @@
if script.meta_type == PythonScript.meta_type:
self.assertEqual( script.manage_FTPget(), expected[ 1 ] )
+ def test_scripts_with_invalid_meta_type(self):
+ """
+ A script with an invalid meta_type should raise an error.
+ Otherwise the previous script will be added for that script.
+ """
+ from Products.DCWorkflow import exportimport
+
+ tool = self._importNormalWorkflow(
+ 'dcworkflow_scripts', 'DC Workflow testing scripts',
+ 'Testing Scripts', 'closed')
+ workflow = tool.objectValues()[1]
+ scripts = workflow.scripts
+
+ s_infos = [
+ dict(script_id='invalid', meta_type='invalid',
+ filename='')]
+ self.assertRaises(ValueError,
+ exportimport._initDCWorkflowScripts,
+ workflow, s_infos, None)
+
+ def test_scripts_by_meta_type(self):
+ """
+ Constructors for meta_types other than those hard coded should
+ be looked up.
+ """
+ from Products.DCWorkflow import exportimport
+
+ tool = self._importNormalWorkflow(
+ 'dcworkflow_scripts', 'DC Workflow testing scripts',
+ 'Testing Scripts', 'closed')
+ workflow = tool.objectValues()[1]
+ scripts = workflow.scripts
+
+ scripts.all_meta_types = scripts.all_meta_types() + [
+ dict(instance=PythonScript, name='Foo Script')]
+
+ s_infos = [
+ dict(script_id='doc', meta_type='DTML Document',
+ filename=''),
+ dict(script_id='bar', meta_type='Foo Script',
+ filename='')]
+ exportimport._initDCWorkflowScripts(workflow, s_infos, None)
+
+ self.assertEqual(scripts['doc'].meta_type, 'DTML Document')
+ self.assertEqual(scripts['bar'].meta_type, 'Script (Python)')
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite( WorkflowDefinitionConfiguratorTests ),
More information about the Checkins
mailing list