[CMF-checkins] SVN: CMF/branches/1.5/C Issue #373: workflows with scripts failed to export to non-tarball contexts.

Tres Seaver tseaver at palladion.com
Mon Sep 4 15:25:27 EDT 2006


Log message for revision 69960:
  Issue #373:  workflows with scripts failed to export to non-tarball contexts.

Changed:
  U   CMF/branches/1.5/CHANGES.txt
  U   CMF/branches/1.5/CMFSetup/tests/common.py
  U   CMF/branches/1.5/CMFSetup/tests/test_workflow.py
  U   CMF/branches/1.5/CMFSetup/workflow.py

-=-
Modified: CMF/branches/1.5/CHANGES.txt
===================================================================
--- CMF/branches/1.5/CHANGES.txt	2006-09-04 18:29:47 UTC (rev 69959)
+++ CMF/branches/1.5/CHANGES.txt	2006-09-04 19:25:26 UTC (rev 69960)
@@ -1,5 +1,11 @@
 After CMF 1.5.7 
 
+  Bug Fixes
+
+    - CMFSetup.workflow: Split out subdirectory when exporting workflow
+      scripts.
+      (http://www.zope.org/Collectors/CMF/373)
+
   Others
 
     - CMFDefault.Portal:  Reverted deprecation of 'manage_addCMFSite', added

Modified: CMF/branches/1.5/CMFSetup/tests/common.py
===================================================================
--- CMF/branches/1.5/CMFSetup/tests/common.py	2006-09-04 18:29:47 UTC (rev 69959)
+++ CMF/branches/1.5/CMFSetup/tests/common.py	2006-09-04 19:25:26 UTC (rev 69960)
@@ -147,17 +147,21 @@
 
 class DummyExportContext:
 
-    def __init__( self, site ):
+    def __init__( self, site, preserve_subdir=False ):
         self._site = site
         self._wrote = []
+        self._preserve_subdir = preserve_subdir
 
     def getSite( self ):
         return self._site
 
     def writeDataFile( self, filename, text, content_type, subdir=None ):
-        if subdir is not None:
-            filename = '%s/%s' % ( subdir, filename )
-        self._wrote.append( ( filename, text, content_type ) )
+        if self._preserve_subdir:
+            self._wrote.append( ( filename, text, content_type, subdir ) )
+        else:
+            if subdir is not None:
+                filename = '%s/%s' % ( subdir, filename )
+            self._wrote.append( ( filename, text, content_type ) )
 
 class DummyImportContext:
 

Modified: CMF/branches/1.5/CMFSetup/tests/test_workflow.py
===================================================================
--- CMF/branches/1.5/CMFSetup/tests/test_workflow.py	2006-09-04 18:29:47 UTC (rev 69959)
+++ CMF/branches/1.5/CMFSetup/tests/test_workflow.py	2006-09-04 19:25:26 UTC (rev 69960)
@@ -2134,7 +2134,7 @@
         self._initWorklists( dcworkflow )
         self._initScripts( dcworkflow )
 
-        context = DummyExportContext( site )
+        context = DummyExportContext( site, preserve_subdir=True )
 
         from Products.CMFSetup.workflow import exportWorkflowTool
         exportWorkflowTool( context )
@@ -2142,13 +2142,14 @@
         # workflows list, wf defintion and 3 scripts
         self.assertEqual( len( context._wrote ), 5 )
 
-        filename, text, content_type = context._wrote[ 0 ]
+        filename, text, content_type, subdir = context._wrote[ 0 ]
         self.assertEqual( filename, 'workflows.xml' )
         self._compareDOM( text, _NORMAL_TOOL_EXPORT )
         self.assertEqual( content_type, 'text/xml' )
+        self.assertEqual( subdir, None )
 
-        filename, text, content_type = context._wrote[ 1 ]
-        self.assertEqual( filename, 'workflows/%s/definition.xml' % WF_ID_DC )
+        filename, text, content_type, subdir = context._wrote[ 1 ]
+        self.assertEqual( filename, 'definition.xml' )
         self._compareDOM( text
                         , _NORMAL_WORKFLOW_EXPORT
                           % { 'workflow_id' : WF_ID_DC
@@ -2157,12 +2158,14 @@
                             , 'workflow_filename' : WF_ID_DC.replace(' ', '_')
                             } )
         self.assertEqual( content_type, 'text/xml' )
+        self.assertEqual( subdir, 'workflows/%s' % WF_ID_DC )
 
         # just testing first script
-        filename, text, content_type = context._wrote[ 2 ]
-        self.assertEqual( filename, 'workflows/%s/scripts/after_close.py' % WF_ID_DC )
+        filename, text, content_type, subdir = context._wrote[ 2 ]
+        self.assertEqual( filename, 'after_close.py' )
         self.assertEqual( text, _AFTER_CLOSE_SCRIPT)
         self.assertEqual( content_type, 'text/plain' )
+        self.assertEqual( subdir, 'workflows/%s/scripts' % WF_ID_DC )
 
     def test_with_filenames( self ):
 
@@ -2182,7 +2185,7 @@
         self._initWorklists( dcworkflow )
         self._initScripts( dcworkflow )
 
-        context = DummyExportContext( site )
+        context = DummyExportContext( site, preserve_subdir=True )
 
         from Products.CMFSetup.workflow import exportWorkflowTool
         exportWorkflowTool( context )
@@ -2190,14 +2193,14 @@
         # workflows list, wf defintion and 3 scripts
         self.assertEqual( len( context._wrote ), 5 )
 
-        filename, text, content_type = context._wrote[ 0 ]
+        filename, text, content_type, subdir = context._wrote[ 0 ]
         self.assertEqual( filename, 'workflows.xml' )
         self._compareDOM( text, _FILENAME_TOOL_EXPORT )
         self.assertEqual( content_type, 'text/xml' )
+        self.assertEqual( subdir, None )
 
-        filename, text, content_type = context._wrote[ 1 ]
-        self.assertEqual( filename
-                        , 'workflows/name_with_spaces/definition.xml' )
+        filename, text, content_type, subdir = context._wrote[ 1 ]
+        self.assertEqual( filename, 'definition.xml' )
         self._compareDOM( text
                         , _NORMAL_WORKFLOW_EXPORT
                           % { 'workflow_id' : WF_ID_DC
@@ -2206,13 +2209,15 @@
                             , 'workflow_filename' : WF_ID_DC.replace(' ', '_')
                             } )
         self.assertEqual( content_type, 'text/xml' )
+        self.assertEqual( subdir, 'workflows/name_with_spaces' )
 
         # just testing first script
-        filename, text, content_type = context._wrote[ 2 ]
-        self.assertEqual( filename, 'workflows/%s/scripts/after_close.py' %
-                          WF_ID_DC.replace(' ', '_'))
+        filename, text, content_type, subdir = context._wrote[ 2 ]
+        self.assertEqual( filename, 'after_close.py' )
         self.assertEqual( text, _AFTER_CLOSE_SCRIPT)
         self.assertEqual( content_type, 'text/plain' )
+        self.assertEqual( subdir, 'workflows/%s/scripts'
+                                        % WF_ID_DC.replace(' ', '_'))
 
 class Test_importWorkflow( _WorkflowSetup
                          , _GuardChecker

Modified: CMF/branches/1.5/CMFSetup/workflow.py
===================================================================
--- CMF/branches/1.5/CMFSetup/workflow.py	2006-09-04 18:29:47 UTC (rev 69959)
+++ CMF/branches/1.5/CMFSetup/workflow.py	2006-09-04 19:25:26 UTC (rev 69960)
@@ -190,16 +190,24 @@
         wf_scripts = wfdc.getWorkflowScripts(wf_id)
 
         if wf_xml is not None:
+            wf_dir = 'workflows/%s' % wf_dirname
             context.writeDataFile( 'definition.xml'
                                  , wf_xml
                                  , 'text/xml'
                                  , 'workflows/%s' % wf_dirname
                                  )
             for script_info in wf_scripts:
-                if script_info['filename']:
-                    context.writeDataFile(script_info['filename'],
+                filename = script_info['filename']
+                if filename:
+                    if '/' in filename:
+                        subdir, filename = filename.rsplit('/', 1)
+                    else:
+                        subdir = ''
+                    context.writeDataFile(filename,
                                           script_info['body'],
-                                          'text/plain')
+                                          'text/plain',
+                                          subdir,
+                                          )
 
     return 'Workflows exported.'
 



More information about the CMF-checkins mailing list