[CMF-checkins] CVS: CMF/CMFSetup - workflow.py:1.21

Tres Seaver tseaver at zope.com
Thu Jun 24 16:18:37 EDT 2004


Update of /cvs-repository/CMF/CMFSetup
In directory cvs.zope.org:/tmp/cvs-serv28198

Modified Files:
	workflow.py 
Log Message:


  - Add import of DCWorkflow scripts
  
    o XXX: only PythonScripts are currently tested.


=== CMF/CMFSetup/workflow.py 1.20 => 1.21 ===
--- CMF/CMFSetup/workflow.py:1.20	Thu Jun 24 15:44:20 2004
+++ CMF/CMFSetup/workflow.py	Thu Jun 24 16:18:07 2004
@@ -110,6 +110,7 @@
                                , worklists
                                , permissions
                                , scripts
+                               , context
                                )
             else:
                 pass # TODO: handle non-DCWorkflows
@@ -1053,12 +1054,12 @@
     if isinstance( value, bool ):
         return 'bool'
 
-    if isinstance( value, float ):
-        return 'float'
-
     if isinstance( value, int ):
         return 'int'
 
+    if isinstance( value, float ):
+        return 'float'
+
     if isinstance( value, basestring ):
         return 'string'
 
@@ -1121,6 +1122,7 @@
                    , worklists
                    , permissions
                    , scripts
+                   , context
                    ):
     """ Initialize a DC Workflow using values parsed from XML.
     """
@@ -1136,6 +1138,7 @@
     _initDCWorkflowStates( workflow, states )
     _initDCWorkflowTransitions( workflow, transitions )
     _initDCWorkflowWorklists( workflow, worklists )
+    _initDCWorkflowScripts( workflow, scripts, context )
 
 
 def _initDCWorkflowVariables( workflow, variables ):
@@ -1280,3 +1283,27 @@
                        )
 
         w.var_matches = PersistentMapping( w_info[ 'match' ].items() )
+
+def _initDCWorkflowScripts( workflow, scripts, context ):
+
+    """ Initialize DCWorkflow scripts
+    """
+    for s_info in scripts:
+
+        id = str( s_info[ 'script_id' ] ) # no unicode!
+        meta_type = s_info[ 'meta_type' ]
+        filename = s_info[ 'filename' ]
+
+        file = context.readDataFile( filename )
+
+        if meta_type == PythonScript.meta_type:
+            script = PythonScript( id )
+            script.write( file )
+
+        #elif meta_type == ExternalMethod.meta_type:
+        #    script = ExternalMethod( id, title, module, function )
+
+        elif meta_type == DTMLMethod.meta_type:
+            script = DTMLMethod( file, __name__=id )
+
+        workflow.scripts._setObject( id, script )



More information about the CMF-checkins mailing list