[Checkins] SVN: CMF/branches/1.6/DCWorkflow/ merge r80702 from
CMF/trunk/DCWorkflow
Ross Patterson
me at rpatterson.net
Mon Oct 8 00:25:58 EDT 2007
Log message for revision 80703:
merge r80702 from CMF/trunk/DCWorkflow
Raise an error for invalid script meta_types, handle arbitrary script
meta_types
Changed:
U CMF/branches/1.6/DCWorkflow/exportimport.py
U CMF/branches/1.6/DCWorkflow/tests/test_exportimport.py
-=-
Modified: CMF/branches/1.6/DCWorkflow/exportimport.py
===================================================================
--- CMF/branches/1.6/DCWorkflow/exportimport.py 2007-10-08 03:43:41 UTC (rev 80702)
+++ CMF/branches/1.6/DCWorkflow/exportimport.py 2007-10-08 04:25:56 UTC (rev 80703)
@@ -1139,6 +1139,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/1.6/DCWorkflow/tests/test_exportimport.py
===================================================================
--- CMF/branches/1.6/DCWorkflow/tests/test_exportimport.py 2007-10-08 03:43:41 UTC (rev 80702)
+++ CMF/branches/1.6/DCWorkflow/tests/test_exportimport.py 2007-10-08 04:25:56 UTC (rev 80703)
@@ -2377,7 +2377,55 @@
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',
+ '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',
+ 'closed')
+ workflow = tool.objectValues()[1]
+ scripts = workflow.scripts
+
+ scripts.all_meta_types = scripts.all_meta_types() + [
+ dict(instance=PythonScript, name='Foo Script')]
+ for mt in scripts.all_meta_types:
+ mt.pop('permission', None)
+
+ 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