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

Tres Seaver tseaver at zope.com
Thu Jun 24 15:44:50 EDT 2004


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

Modified Files:
	workflow.py 
Log Message:


  - Add import of DCWorkflow worklists.

  - Wrap newly-created subobjects before manipulating.


=== CMF/CMFSetup/workflow.py 1.19 => 1.20 ===
--- CMF/CMFSetup/workflow.py:1.19	Thu Jun 24 15:22:11 2004
+++ CMF/CMFSetup/workflow.py	Thu Jun 24 15:44:20 2004
@@ -2,6 +2,7 @@
 
 $Id$
 """
+import re
 from xml.sax import parseString
 from xml.dom.minidom import parseString as domParseString
 
@@ -1023,6 +1024,8 @@
            , 'expression' : expr_text
            }
 
+_SEMICOLON_LIST_SPLITTER = re.compile( r';[ ]*' )
+
 def _extractMatchNode( parent, encoding=None ):
 
     nodes = parent.getElementsByTagName( 'match' )
@@ -1033,7 +1036,7 @@
 
         name = _getNodeAttribute( node, 'name', encoding )
         values = _getNodeAttribute( node, 'values', encoding )
-        result[ name ] = values.split()
+        result[ name ] = _SEMICOLON_LIST_SPLITTER.split( values )
 
     return result
 
@@ -1132,6 +1135,7 @@
     _initDCWorkflowVariables( workflow, variables )
     _initDCWorkflowStates( workflow, states )
     _initDCWorkflowTransitions( workflow, transitions )
+    _initDCWorkflowWorklists( workflow, worklists )
 
 
 def _initDCWorkflowVariables( workflow, variables ):
@@ -1144,6 +1148,8 @@
 
         id = str( v_info[ 'variable_id' ] ) # no unicode!
         v = VariableDefinition( id )
+        workflow.variables._setObject( id, v )
+        v = workflow.variables._getOb( id )
 
         guard = v_info[ 'guard' ]
         props = { 'guard_roles' : ';'.join( guard[ 'roles' ] )
@@ -1165,8 +1171,6 @@
                        , props = props
                        )
 
-        workflow.variables._setObject( id, v )
-
 
 def _initDCWorkflowStates( workflow, states ):
 
@@ -1179,6 +1183,8 @@
 
         id = str( s_info[ 'state_id' ] ) # no unicode!
         s = StateDefinition( id )
+        workflow.states._setObject( id, s )
+        s = workflow.states._getOb( id )
 
         s.setProperties( title = s_info[ 'title' ]
                        , description = s_info[ 'description' ]
@@ -1202,8 +1208,6 @@
 
             vmap[ name ] = value
 
-        workflow.states._setObject( id, s )
-
 
 def _initDCWorkflowTransitions( workflow, transitions ):
 
@@ -1216,6 +1220,8 @@
 
         id = str( t_info[ 'transition_id' ] ) # no unicode!
         t = TransitionDefinition( id )
+        workflow.transitions._setObject( id, t )
+        t = workflow.transitions._getOb( id )
 
         trigger_type = list( TRIGGER_TYPES ).index( t_info[ 'trigger' ] )
 
@@ -1242,4 +1248,35 @@
 
         t.var_exprs = PersistentMapping( t_info[ 'variables' ].items() )
 
-        workflow.transitions._setObject( id, t )
+def _initDCWorkflowWorklists( workflow, worklists ):
+
+    """ Initialize DCWorkflow worklists
+    """
+    from Globals import PersistentMapping
+    from Products.DCWorkflow.Worklists import WorklistDefinition
+
+    for w_info in worklists:
+
+        id = str( w_info[ 'worklist_id' ] ) # no unicode!
+        w = WorklistDefinition( id )
+        workflow.worklists._setObject( id, w )
+
+        w = workflow.worklists._getOb( id )
+
+        action = w_info[ 'action' ]
+
+        guard = w_info[ 'guard' ]
+        props = { 'guard_roles' : ';'.join( guard[ 'roles' ] )
+                , 'guard_permissions' : ';'.join( guard[ 'permissions' ] )
+                , 'guard_groups' : ';'.join( guard[ 'groups' ] )
+                , 'guard_expr' : guard[ 'expression' ]
+                }
+
+        w.setProperties( description = w_info[ 'description' ]
+                       , actbox_name = action[ 'name' ]
+                       , actbox_url = action[ 'url' ]
+                       , actbox_category = action[ 'category' ]
+                       , props = props
+                       )
+
+        w.var_matches = PersistentMapping( w_info[ 'match' ].items() )



More information about the CMF-checkins mailing list