Back to index

plone3  3.1.7
Classes | Functions | Variables
DCWorkflow.exportimport Namespace Reference

Classes

class  DCWorkflowDefinitionBodyAdapter
class  WorkflowDefinitionConfigurator

Functions

def _getScriptFilename
def _extractStateNodes
def _extractTransitionNodes
def _extractVariableNodes
def _extractWorklistNodes
def _extractScriptNodes
def _extractPermissionNodes
def _extractActionNode
def _extractGuardNode
def _extractDefaultNode
def _extractMatchNode
def _guessVariableType
def _convertVariableValue
def _initDCWorkflow
def _initDCWorkflowVariables
def _initDCWorkflowStates
def _initDCWorkflowTransitions
def _initDCWorkflowWorklists
def _initDCWorkflowScripts
def _queryNodeAttribute
def _getNodeAttribute
def _queryNodeAttributeBoolean
def _getNodeAttributeBoolean
def _coalesceTextNodeChildren
def _extractDescriptionNode

Variables

tuple TRIGGER_TYPES = ( 'AUTOMATIC', 'USER' )
string _FILENAME = 'workflows.xml'
tuple _SEMICOLON_LIST_SPLITTER = re.compile( r';[ ]*' )
 _METATYPE_SUFFIXES = \
tuple _marker = object()

Function Documentation

def DCWorkflow.exportimport._coalesceTextNodeChildren (   node,
  encoding = None 
) [private]
Concatenate all childe text nodes into a single string.

Definition at line 1232 of file exportimport.py.

01232 
01233 def _coalesceTextNodeChildren( node, encoding=None ):
01234 
01235     """ Concatenate all childe text nodes into a single string.
01236     """
01237     from xml.dom import Node
01238     fragments = []
01239     node.normalize()
01240     child = node.firstChild
01241 
01242     while child is not None:
01243 
01244         if child.nodeType == Node.TEXT_NODE:
01245             fragments.append( child.nodeValue )
01246 
01247         child = child.nextSibling
01248 
01249     joined = ''.join( fragments )
01250 
01251     if encoding is not None:
01252         joined = joined.encode( encoding )
01253 
01254     return ''.join( [ line.lstrip() for line in joined.splitlines(True) ] )

Here is the caller graph for this function:

def DCWorkflow.exportimport._convertVariableValue (   value,
  type_id 
) [private]

Definition at line 912 of file exportimport.py.

00912 
00913 def _convertVariableValue( value, type_id ):
00914 
00915     from DateTime.DateTime import DateTime
00916 
00917     if type_id == 'none':
00918         return None
00919 
00920     if type_id == 'datetime':
00921 
00922         return DateTime( value )
00923 
00924     if type_id == 'bool':
00925 
00926         if isinstance( value, basestring ):
00927 
00928             value = str( value ).lower()
00929 
00930             return value in ( 'true', 'yes', '1' )
00931 
00932         else:
00933             return bool( value )
00934 
00935     if type_id == 'int':
00936         return int( value )
00937 
00938     if type_id == 'float':
00939         return float( value )
00940 
00941     return value

Here is the caller graph for this function:

def DCWorkflow.exportimport._extractActionNode (   parent,
  encoding = None 
) [private]

Definition at line 797 of file exportimport.py.

00797 
00798 def _extractActionNode( parent, encoding=None ):
00799 
00800     nodes = parent.getElementsByTagName( 'action' )
00801     assert len( nodes ) <= 1, nodes
00802 
00803     if len( nodes ) < 1:
00804         return { 'name' : '', 'url' : '', 'category' : '' }
00805 
00806     node = nodes[ 0 ]
00807 
00808     return { 'name' : _coalesceTextNodeChildren( node, encoding )
00809            , 'url' : _getNodeAttribute( node, 'url', encoding )
00810            , 'category' : _getNodeAttribute( node, 'category', encoding )
00811            }

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._extractDefaultNode (   parent,
  encoding = None 
) [private]

Definition at line 839 of file exportimport.py.

00839 
00840 def _extractDefaultNode( parent, encoding=None ):
00841 
00842     nodes = parent.getElementsByTagName( 'default' )
00843     assert len( nodes ) <= 1, nodes
00844 
00845     if len( nodes ) < 1:
00846         return { 'value' : '', 'expression' : '', 'type' : 'n/a' }
00847 
00848     node = nodes[ 0 ]
00849 
00850     value_nodes = node.getElementsByTagName( 'value' )
00851     assert( len( value_nodes ) <= 1 )
00852 
00853     value_type = 'n/a'
00854     if value_nodes:
00855         value_type = value_nodes[ 0 ].getAttribute( 'type' ) or 'n/a'
00856 
00857     value_text = value_nodes and _coalesceTextNodeChildren( value_nodes[ 0 ]
00858                                                           , encoding
00859                                                           ) or ''
00860 
00861     expr_nodes = node.getElementsByTagName( 'expression' )
00862     assert( len( expr_nodes ) <= 1 )
00863 
00864     expr_text = expr_nodes and _coalesceTextNodeChildren( expr_nodes[ 0 ]
00865                                                         , encoding
00866                                                         ) or ''
00867 
00868     return { 'value' : value_text
00869            , 'type' : value_type
00870            , 'expression' : expr_text
00871            }

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._extractDescriptionNode (   parent,
  encoding = None 
) [private]

Definition at line 1255 of file exportimport.py.

01255 
01256 def _extractDescriptionNode(parent, encoding=None):
01257 
01258     d_nodes = parent.getElementsByTagName('description')
01259     if d_nodes:
01260         return _coalesceTextNodeChildren(d_nodes[0], encoding)
01261     else:
01262         return ''

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._extractGuardNode (   parent,
  encoding = None 
) [private]

Definition at line 812 of file exportimport.py.

00812 
00813 def _extractGuardNode( parent, encoding=None ):
00814 
00815     nodes = parent.getElementsByTagName( 'guard' )
00816     assert len( nodes ) <= 1, nodes
00817 
00818     if len( nodes ) < 1:
00819         return { 'permissions' : (), 'roles' : (), 'groups' : (), 'expr' : '' }
00820 
00821     node = nodes[ 0 ]
00822 
00823     expr_nodes = node.getElementsByTagName( 'guard-expression' )
00824     assert( len( expr_nodes ) <= 1 )
00825 
00826     expr_text = expr_nodes and _coalesceTextNodeChildren( expr_nodes[ 0 ]
00827                                                         , encoding
00828                                                         ) or ''
00829 
00830     return { 'permissions' : [ _coalesceTextNodeChildren( x, encoding )
00831                                 for x in node.getElementsByTagName(
00832                                                     'guard-permission' ) ]
00833            , 'roles' : [ _coalesceTextNodeChildren( x, encoding )
00834                           for x in node.getElementsByTagName( 'guard-role' ) ]
00835            , 'groups' : [ _coalesceTextNodeChildren( x, encoding )
00836                           for x in node.getElementsByTagName( 'guard-group' ) ]
00837            , 'expression' : expr_text
00838            }

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._extractMatchNode (   parent,
  encoding = None 
) [private]

Definition at line 874 of file exportimport.py.

00874 
00875 def _extractMatchNode( parent, encoding=None ):
00876 
00877     nodes = parent.getElementsByTagName( 'match' )
00878 
00879     result = {}
00880 
00881     for node in nodes:
00882 
00883         name = _getNodeAttribute( node, 'name', encoding )
00884         values = _getNodeAttribute( node, 'values', encoding )
00885         result[ name ] = _SEMICOLON_LIST_SPLITTER.split( values )
00886 
00887     return result

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._extractPermissionNodes (   root,
  encoding = None 
) [private]

Definition at line 787 of file exportimport.py.

00787 
00788 def _extractPermissionNodes( root, encoding=None ):
00789 
00790     result = []
00791 
00792     for p_node in root.getElementsByTagName( 'permission' ):
00793 
00794         result.append( _coalesceTextNodeChildren( p_node, encoding ) )
00795 
00796     return result

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._extractScriptNodes (   root,
  encoding = None 
) [private]

Definition at line 756 of file exportimport.py.

00756 
00757 def _extractScriptNodes( root, encoding=None ):
00758 
00759     result = []
00760 
00761     for s_node in root.getElementsByTagName( 'script' ):
00762 
00763         try:
00764             function = _getNodeAttribute( s_node, 'function' )
00765         except ValueError:
00766             function = ''
00767 
00768         try:
00769             module = _getNodeAttribute( s_node, 'module' )
00770         except ValueError:
00771             module = ''
00772 
00773         info = { 'script_id' : _getNodeAttribute( s_node, 'script_id' )
00774                , 'meta_type' : _getNodeAttribute( s_node, 'type' , encoding )
00775                , 'function'  : function
00776                , 'module'    : module
00777                }
00778 
00779         filename = _queryNodeAttribute( s_node, 'filename' , None, encoding )
00780 
00781         if filename is not None:
00782             info[ 'filename' ] = filename
00783 
00784         result.append( info )
00785 
00786     return result

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._extractStateNodes (   root,
  encoding = None 
) [private]

Definition at line 617 of file exportimport.py.

00617 
00618 def _extractStateNodes( root, encoding=None ):
00619 
00620     result = []
00621 
00622     for s_node in root.getElementsByTagName( 'state' ):
00623 
00624         info = { 'state_id' : _getNodeAttribute( s_node, 'state_id', encoding )
00625                , 'title' : _getNodeAttribute( s_node, 'title', encoding )
00626                , 'description' : _extractDescriptionNode( s_node, encoding )
00627                }
00628 
00629         info[ 'transitions' ] = [ _getNodeAttribute( x, 'transition_id'
00630                                                    , encoding )
00631                                   for x in s_node.getElementsByTagName(
00632                                                         'exit-transition' ) ]
00633 
00634         info[ 'permissions' ] = permission_map = {}
00635 
00636         for p_map in s_node.getElementsByTagName( 'permission-map' ):
00637 
00638             name = _getNodeAttribute( p_map, 'name', encoding )
00639             acquired = _getNodeAttributeBoolean( p_map, 'acquired' )
00640 
00641             roles = [ _coalesceTextNodeChildren( x, encoding )
00642                         for x in p_map.getElementsByTagName(
00643                                             'permission-role' ) ]
00644 
00645             if not acquired:
00646                 roles = tuple( roles )
00647 
00648             permission_map[ name ] = roles
00649 
00650         info[ 'groups' ] = group_map = []
00651 
00652         for g_map in s_node.getElementsByTagName( 'group-map' ):
00653 
00654             name = _getNodeAttribute( g_map, 'name', encoding )
00655 
00656             roles = [ _coalesceTextNodeChildren( x, encoding )
00657                         for x in g_map.getElementsByTagName(
00658                                             'group-role' ) ]
00659 
00660             group_map.append( ( name, tuple( roles ) ) )
00661 
00662         info[ 'variables' ] = var_map = {}
00663 
00664         for assignment in s_node.getElementsByTagName( 'assignment' ):
00665 
00666             name = _getNodeAttribute( assignment, 'name', encoding )
00667             type_id = _getNodeAttribute( assignment, 'type', encoding )
00668             value = _coalesceTextNodeChildren( assignment, encoding )
00669 
00670             var_map[ name ] = { 'name'  : name
00671                               , 'type'  : type_id
00672                               , 'value' : value
00673                               }
00674 
00675         result.append( info )
00676 
00677     return result

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._extractTransitionNodes (   root,
  encoding = None 
) [private]

Definition at line 678 of file exportimport.py.

00678 
00679 def _extractTransitionNodes( root, encoding=None ):
00680 
00681     result = []
00682 
00683     for t_node in root.getElementsByTagName( 'transition' ):
00684 
00685         info = { 'transition_id' : _getNodeAttribute( t_node, 'transition_id'
00686                                                     , encoding )
00687                , 'title' : _getNodeAttribute( t_node, 'title', encoding )
00688                , 'description' : _extractDescriptionNode( t_node, encoding )
00689                , 'new_state' : _getNodeAttribute( t_node, 'new_state'
00690                                                 , encoding )
00691                , 'trigger' : _getNodeAttribute( t_node, 'trigger', encoding )
00692                , 'before_script' : _getNodeAttribute( t_node, 'before_script'
00693                                                   , encoding )
00694                , 'after_script' : _getNodeAttribute( t_node, 'after_script'
00695                                                    , encoding )
00696                , 'action' : _extractActionNode( t_node, encoding )
00697                , 'guard' : _extractGuardNode( t_node, encoding )
00698                }
00699 
00700         info[ 'variables' ] = var_map = {}
00701 
00702         for assignment in t_node.getElementsByTagName( 'assignment' ):
00703 
00704             name = _getNodeAttribute( assignment, 'name', encoding )
00705             expr = _coalesceTextNodeChildren( assignment, encoding )
00706             var_map[ name ] = expr
00707 
00708         result.append( info )
00709 
00710     return result

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._extractVariableNodes (   root,
  encoding = None 
) [private]

Definition at line 711 of file exportimport.py.

00711 
00712 def _extractVariableNodes( root, encoding=None ):
00713 
00714     result = []
00715 
00716     for v_node in root.getElementsByTagName( 'variable' ):
00717 
00718         info = { 'variable_id' : _getNodeAttribute( v_node, 'variable_id'
00719                                                     , encoding )
00720                , 'description' : _extractDescriptionNode( v_node, encoding )
00721                , 'for_catalog' : _getNodeAttributeBoolean( v_node
00722                                                          , 'for_catalog'
00723                                                          )
00724                , 'for_status' : _getNodeAttributeBoolean( v_node
00725                                                         , 'for_status'
00726                                                         )
00727                , 'update_always' : _getNodeAttributeBoolean( v_node
00728                                                            , 'update_always'
00729                                                            )
00730                , 'default' : _extractDefaultNode( v_node, encoding )
00731                , 'guard' : _extractGuardNode( v_node, encoding )
00732                }
00733 
00734         result.append( info )
00735 
00736     return result

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._extractWorklistNodes (   root,
  encoding = None 
) [private]

Definition at line 737 of file exportimport.py.

00737 
00738 def _extractWorklistNodes( root, encoding=None ):
00739 
00740     result = []
00741 
00742     for w_node in root.getElementsByTagName( 'worklist' ):
00743 
00744         info = { 'worklist_id' : _getNodeAttribute( w_node, 'worklist_id'
00745                                                     , encoding )
00746                , 'title' : _getNodeAttribute( w_node, 'title' , encoding )
00747                , 'description' : _extractDescriptionNode( w_node, encoding )
00748                , 'match' : _extractMatchNode( w_node, encoding )
00749                , 'action' : _extractActionNode( w_node, encoding )
00750                , 'guard' : _extractGuardNode( w_node, encoding )
00751                }
00752 
00753         result.append( info )
00754 
00755     return result

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._getNodeAttribute (   node,
  attr_name,
  encoding = None 
) [private]
Extract a string-valued attribute from node.

Definition at line 1198 of file exportimport.py.

01198 
01199 def _getNodeAttribute( node, attr_name, encoding=None ):
01200 
01201     """ Extract a string-valued attribute from node.
01202     """
01203     value = _queryNodeAttribute( node, attr_name, _marker, encoding )
01204 
01205     if value is _marker:
01206         raise ValueError, 'Invalid attribute: %s' % attr_name
01207 
01208     return value

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._getNodeAttributeBoolean (   node,
  attr_name 
) [private]
Extract a string-valued attribute from node.

Definition at line 1224 of file exportimport.py.

01224 
01225 def _getNodeAttributeBoolean( node, attr_name ):
01226 
01227     """ Extract a string-valued attribute from node.
01228     """
01229     value = node.attributes[ attr_name ].nodeValue.lower()
01230 
01231     return value in ( 'true', 'yes', '1' )

Here is the caller graph for this function:

def DCWorkflow.exportimport._getScriptFilename (   workflow_id,
  script_id,
  meta_type 
) [private]
Return the name of the file which holds the script.

Definition at line 605 of file exportimport.py.

00605 
00606 def _getScriptFilename( workflow_id, script_id, meta_type ):
00607 
00608     """ Return the name of the file which holds the script.
00609     """
00610     wf_dir = workflow_id.replace( ' ', '_' )
00611     suffix = _METATYPE_SUFFIXES.get(meta_type, None)
00612 
00613     if suffix is None:
00614         return ''
00615 
00616     return 'workflows/%s/scripts/%s.%s' % ( wf_dir, script_id, suffix )

Here is the caller graph for this function:

def DCWorkflow.exportimport._guessVariableType (   value) [private]

Definition at line 888 of file exportimport.py.

00888 
00889 def _guessVariableType( value ):
00890 
00891     from DateTime.DateTime import DateTime
00892 
00893     if value is None:
00894         return 'none'
00895 
00896     if isinstance( value, DateTime ):
00897         return 'datetime'
00898 
00899     if isinstance( value, bool ):
00900         return 'bool'
00901 
00902     if isinstance( value, int ):
00903         return 'int'
00904 
00905     if isinstance( value, float ):
00906         return 'float'
00907 
00908     if isinstance( value, basestring ):
00909         return 'string'
00910 
00911     return 'unknown'

Here is the caller graph for this function:

def DCWorkflow.exportimport._initDCWorkflow (   workflow,
  title,
  description,
  state_variable,
  initial_state,
  states,
  transitions,
  variables,
  worklists,
  permissions,
  scripts,
  context 
) [private]
Initialize a DC Workflow using values parsed from XML.

Definition at line 963 of file exportimport.py.

00963 
00964                    ):
00965     """ Initialize a DC Workflow using values parsed from XML.
00966     """
00967     workflow.title = title
00968     workflow.description = description
00969     workflow.state_var = state_variable
00970     workflow.initial_state = initial_state
00971 
00972     permissions = permissions[:]
00973     permissions.sort()
00974     workflow.permissions = tuple(permissions)
00975 
00976     _initDCWorkflowVariables( workflow, variables )
00977     _initDCWorkflowStates( workflow, states )
00978     _initDCWorkflowTransitions( workflow, transitions )
00979     _initDCWorkflowWorklists( workflow, worklists )
00980     _initDCWorkflowScripts( workflow, scripts, context )
00981 

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._initDCWorkflowScripts (   workflow,
  scripts,
  context 
) [private]
Initialize DCWorkflow scripts

Definition at line 1131 of file exportimport.py.

01131 
01132 def _initDCWorkflowScripts( workflow, scripts, context ):
01133 
01134     """ Initialize DCWorkflow scripts
01135     """
01136     for s_info in scripts:
01137 
01138         id = str( s_info[ 'script_id' ] ) # no unicode!
01139         meta_type = s_info[ 'meta_type' ]
01140         filename = s_info[ 'filename' ]
01141         file = ''
01142 
01143         if filename:
01144             file = context.readDataFile( filename )
01145 
01146         if meta_type == PythonScript.meta_type:
01147             script = PythonScript( id )
01148             script.write( file )
01149 
01150         elif meta_type == ExternalMethod.meta_type:
01151             script = ExternalMethod( id
01152                                    , ''
01153                                    , s_info['module']
01154                                    , s_info['function']
01155                                    )
01156 
01157         elif meta_type == DTMLMethod.meta_type:
01158             script = DTMLMethod( file, __name__=id )
01159 
01160         else:
01161             for mt in workflow.scripts.filtered_meta_types():
01162                 if mt['name']==meta_type:
01163                     if hasattr(mt['instance'], 'write'):
01164                         script = mt['instance'](id)
01165                         script.write(file)
01166                     else:
01167                         script = mt['instance'](file, __name__=id)
01168                     break
01169             else:
01170                 raise ValueError, 'Invalid type: %s' % meta_type
01171 
01172         if workflow.scripts.has_key(id):
01173             workflow.scripts._delObject(id)
01174         workflow.scripts._setObject( id, script )
01175 
01176 #
01177 #   deprecated DOM parsing utilities
#

Here is the caller graph for this function:

def DCWorkflow.exportimport._initDCWorkflowStates (   workflow,
  states 
) [private]
Initialize DCWorkflow states

Definition at line 1017 of file exportimport.py.

01017 
01018 def _initDCWorkflowStates( workflow, states ):
01019 
01020     """ Initialize DCWorkflow states
01021     """
01022     from Globals import PersistentMapping
01023     from Products.DCWorkflow.States import StateDefinition
01024 
01025     for s_info in states:
01026 
01027         id = str( s_info[ 'state_id' ] ) # no unicode!
01028         if not workflow.states.has_key(id):
01029             s = StateDefinition(id)
01030             workflow.states._setObject(id, s)
01031         s = workflow.states._getOb( id )
01032 
01033         s.setProperties( title = s_info[ 'title' ]
01034                        , description = s_info[ 'description' ]
01035                        , transitions = s_info[ 'transitions' ]
01036                        )
01037 
01038         for k, v in s_info[ 'permissions' ].items():
01039             s.setPermission( k, isinstance(v, list), v )
01040 
01041         gmap = s.group_roles = PersistentMapping()
01042 
01043         for group_id, roles in s_info[ 'groups' ]:
01044             gmap[ group_id ] = roles
01045 
01046         vmap = s.var_values = PersistentMapping()
01047 
01048         for name, v_info in s_info[ 'variables' ].items():
01049 
01050             value = _convertVariableValue( v_info[ 'value' ]
01051                                          , v_info[ 'type' ] )
01052 
01053             vmap[ name ] = value
01054 

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._initDCWorkflowTransitions (   workflow,
  transitions 
) [private]
Initialize DCWorkflow transitions

Definition at line 1055 of file exportimport.py.

01055 
01056 def _initDCWorkflowTransitions( workflow, transitions ):
01057 
01058     """ Initialize DCWorkflow transitions
01059     """
01060     from Globals import PersistentMapping
01061     from Products.DCWorkflow.Transitions import TransitionDefinition
01062 
01063     for t_info in transitions:
01064 
01065         id = str( t_info[ 'transition_id' ] ) # no unicode!
01066         if not workflow.transitions.has_key(id):
01067             t = TransitionDefinition(id)
01068             workflow.transitions._setObject(id, t)
01069         t = workflow.transitions._getOb( id )
01070 
01071         trigger_type = list( TRIGGER_TYPES ).index( t_info[ 'trigger' ] )
01072 
01073         action = t_info[ 'action' ]
01074 
01075         guard = t_info[ 'guard' ]
01076         props = { 'guard_roles' : ';'.join( guard[ 'roles' ] )
01077                 , 'guard_permissions' : ';'.join( guard[ 'permissions' ] )
01078                 , 'guard_groups' : ';'.join( guard[ 'groups' ] )
01079                 , 'guard_expr' : guard[ 'expression' ]
01080                 }
01081 
01082         t.setProperties( title = t_info[ 'title' ]
01083                        , description = t_info[ 'description' ]
01084                        , new_state_id = t_info[ 'new_state' ]
01085                        , trigger_type = trigger_type
01086                        , script_name = t_info[ 'before_script' ]
01087                        , after_script_name = t_info[ 'after_script' ]
01088                        , actbox_name = action[ 'name' ]
01089                        , actbox_url = action[ 'url' ]
01090                        , actbox_category = action[ 'category' ]
01091                        , props = props
01092                        )
01093         var_mapping = [(name, Expression(text)) for name, text in
01094                        t_info[ 'variables' ].items()]
01095         t.var_exprs = PersistentMapping(var_mapping)

Here is the caller graph for this function:

def DCWorkflow.exportimport._initDCWorkflowVariables (   workflow,
  variables 
) [private]
Initialize DCWorkflow variables

Definition at line 982 of file exportimport.py.

00982 
00983 def _initDCWorkflowVariables( workflow, variables ):
00984 
00985     """ Initialize DCWorkflow variables
00986     """
00987     from Products.DCWorkflow.Variables import VariableDefinition
00988 
00989     for v_info in variables:
00990 
00991         id = str( v_info[ 'variable_id' ] ) # no unicode!
00992         if not workflow.variables.has_key(id):
00993             v = VariableDefinition(id)
00994             workflow.variables._setObject(id, v)
00995         v = workflow.variables._getOb( id )
00996 
00997         guard = v_info[ 'guard' ]
00998         props = { 'guard_roles' : ';'.join( guard[ 'roles' ] )
00999                 , 'guard_permissions' : ';'.join( guard[ 'permissions' ] )
01000                 , 'guard_groups' : ';'.join( guard[ 'groups' ] )
01001                 , 'guard_expr' : guard[ 'expression' ]
01002                 }
01003 
01004         default = v_info[ 'default' ]
01005         default_value = _convertVariableValue( default[ 'value' ]
01006                                              , default[ 'type' ] )
01007 
01008         v.setProperties( description = v_info[ 'description' ]
01009                        , default_value = default_value
01010                        , default_expr = default[ 'expression' ]
01011                        , for_catalog = v_info[ 'for_catalog' ]
01012                        , for_status = v_info[ 'for_status' ]
01013                        , update_always = v_info[ 'update_always' ]
01014                        , props = props
01015                        )
01016 

Here is the call graph for this function:

Here is the caller graph for this function:

def DCWorkflow.exportimport._initDCWorkflowWorklists (   workflow,
  worklists 
) [private]
Initialize DCWorkflow worklists

Definition at line 1096 of file exportimport.py.

01096 
01097 def _initDCWorkflowWorklists( workflow, worklists ):
01098 
01099     """ Initialize DCWorkflow worklists
01100     """
01101     from Globals import PersistentMapping
01102     from Products.DCWorkflow.Worklists import WorklistDefinition
01103 
01104     for w_info in worklists:
01105 
01106         id = str( w_info[ 'worklist_id' ] ) # no unicode!
01107         if not workflow.worklists.has_key(id):
01108             w = WorklistDefinition(id)
01109             workflow.worklists._setObject(id, w)
01110         w = workflow.worklists._getOb( id )
01111 
01112         action = w_info[ 'action' ]
01113 
01114         guard = w_info[ 'guard' ]
01115         props = { 'guard_roles' : ';'.join( guard[ 'roles' ] )
01116                 , 'guard_permissions' : ';'.join( guard[ 'permissions' ] )
01117                 , 'guard_groups' : ';'.join( guard[ 'groups' ] )
01118                 , 'guard_expr' : guard[ 'expression' ]
01119                 }
01120 
01121         w.setProperties( description = w_info[ 'description' ]
01122                        , actbox_name = action[ 'name' ]
01123                        , actbox_url = action[ 'url' ]
01124                        , actbox_category = action[ 'category' ]
01125                        , props = props
01126                        )
01127 
01128         w.var_matches = PersistentMapping()
01129         for k, v in w_info[ 'match' ].items():
01130             w.var_matches[ str( k ) ] = tuple( [ str(x) for x in v ] )

Here is the caller graph for this function:

def DCWorkflow.exportimport._queryNodeAttribute (   node,
  attr_name,
  default,
  encoding = None 
) [private]
Extract a string-valued attribute from node.

o Return 'default' if the attribute is not present.

Definition at line 1180 of file exportimport.py.

01180 
01181 def _queryNodeAttribute( node, attr_name, default, encoding=None ):
01182 
01183     """ Extract a string-valued attribute from node.
01184 
01185     o Return 'default' if the attribute is not present.
01186     """
01187     attr_node = node.attributes.get( attr_name, _marker )
01188 
01189     if attr_node is _marker:
01190         return default
01191 
01192     value = attr_node.nodeValue
01193 
01194     if encoding is not None:
01195         value = value.encode( encoding )
01196 
01197     return value

Here is the caller graph for this function:

def DCWorkflow.exportimport._queryNodeAttributeBoolean (   node,
  attr_name,
  default 
) [private]
Extract a string-valued attribute from node.

o Return 'default' if the attribute is not present.

Definition at line 1209 of file exportimport.py.

01209 
01210 def _queryNodeAttributeBoolean( node, attr_name, default ):
01211 
01212     """ Extract a string-valued attribute from node.
01213 
01214     o Return 'default' if the attribute is not present.
01215     """
01216     attr_node = node.attributes.get( attr_name, _marker )
01217 
01218     if attr_node is _marker:
01219         return default
01220 
01221     value = node.attributes[ attr_name ].nodeValue.lower()
01222 
01223     return value in ( 'true', 'yes', '1' )


Variable Documentation

string DCWorkflow.exportimport._FILENAME = 'workflows.xml'

Definition at line 38 of file exportimport.py.

Definition at line 1178 of file exportimport.py.

Definition at line 946 of file exportimport.py.

tuple DCWorkflow.exportimport._SEMICOLON_LIST_SPLITTER = re.compile( r';[ ]*' )

Definition at line 872 of file exportimport.py.

tuple DCWorkflow.exportimport.TRIGGER_TYPES = ( 'AUTOMATIC', 'USER' )

Definition at line 37 of file exportimport.py.