Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
DCWorkflow.exportimport.WorkflowDefinitionConfigurator Class Reference
Inheritance diagram for DCWorkflow.exportimport.WorkflowDefinitionConfigurator:
Inheritance graph
[legend]
Collaboration diagram for DCWorkflow.exportimport.WorkflowDefinitionConfigurator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def getWorkflowInfo
def generateWorkflowXML
def getWorkflowScripts
def parseWorkflowXML

Static Public Attributes

tuple security = ClassSecurityInfo()

Private Member Functions

def _extractDCWorkflowInfo
def _extractVariables
def _extractStates
def _extractStatePermissions
def _extractTransitions
def _extractWorklists
def _extractScripts

Private Attributes

 _obj

Static Private Attributes

tuple _workflowConfig

Detailed Description

Synthesize XML description of site's workflows.

Definition at line 94 of file exportimport.py.


Constructor & Destructor Documentation

Definition at line 99 of file exportimport.py.

00099 
00100     def __init__(self, obj):
00101         self._obj = obj


Member Function Documentation

def DCWorkflow.exportimport.WorkflowDefinitionConfigurator._extractDCWorkflowInfo (   self,
  workflow,
  workflow_info 
) [private]
Append the information for a 'workflow' into 'workflow_info'

o 'workflow' must be a DCWorkflowDefinition instance.

o 'workflow_info' must be a dictionary.

o The following keys will be added to 'workflow_info':

  'permissions' -- a list of names of permissions managed
    by the workflow

  'state_variable' -- the name of the workflow's "main"
    state variable

  'initial_state' -- the name of the state in the workflow
    in which objects start their lifecycle.

  'variable_info' -- a list of mappings describing the
    variables tracked by the workflow (see '_extractVariables').

  'state_info' -- a list of mappings describing the
    states tracked by the workflow (see '_extractStates').

  'transition_info' -- a list of mappings describing the
    transitions tracked by the workflow (see '_extractTransitions').

  'worklist_info' -- a list of mappings describing the
    worklists tracked by the workflow (see '_extractWorklists').

  'script_info' -- a list of mappings describing the scripts which
    provide added business logic (see '_extractScripts').

Definition at line 191 of file exportimport.py.

00191 
00192     def _extractDCWorkflowInfo( self, workflow, workflow_info ):
00193 
00194         """ Append the information for a 'workflow' into 'workflow_info'
00195 
00196         o 'workflow' must be a DCWorkflowDefinition instance.
00197 
00198         o 'workflow_info' must be a dictionary.
00199 
00200         o The following keys will be added to 'workflow_info':
00201 
00202           'permissions' -- a list of names of permissions managed
00203             by the workflow
00204 
00205           'state_variable' -- the name of the workflow's "main"
00206             state variable
00207 
00208           'initial_state' -- the name of the state in the workflow
00209             in which objects start their lifecycle.
00210 
00211           'variable_info' -- a list of mappings describing the
00212             variables tracked by the workflow (see '_extractVariables').
00213 
00214           'state_info' -- a list of mappings describing the
00215             states tracked by the workflow (see '_extractStates').
00216 
00217           'transition_info' -- a list of mappings describing the
00218             transitions tracked by the workflow (see '_extractTransitions').
00219 
00220           'worklist_info' -- a list of mappings describing the
00221             worklists tracked by the workflow (see '_extractWorklists').
00222 
00223           'script_info' -- a list of mappings describing the scripts which
00224             provide added business logic (see '_extractScripts').
00225         """
00226         workflow_info[ 'state_variable' ] = workflow.state_var
00227         workflow_info[ 'initial_state' ] = workflow.initial_state
00228         workflow_info[ 'permissions' ] = workflow.permissions
00229         workflow_info[ 'variable_info' ] = self._extractVariables( workflow )
00230         workflow_info[ 'state_info' ] = self._extractStates( workflow )
00231         workflow_info[ 'transition_info' ] = self._extractTransitions(
00232                                                                    workflow )
00233         workflow_info[ 'worklist_info' ] = self._extractWorklists( workflow )
00234         workflow_info[ 'script_info' ] = self._extractScripts( workflow )

Here is the call graph for this function:

Here is the caller graph for this function:

Return a sequence of mappings describing DCWorkflow scripts.

o Each mapping has the keys:

  'id' -- the ID of the script

  'meta_type' -- the title of the worklist

  'body' -- the text of the script (only applicable to scripts
    of type Script (Python))

  'module' -- The module from where to load the function (only
    applicable to External Method scripts)

  'function' -- The function to load from the 'module' given
    (Only applicable to External Method scripts)

  'filename' -- the name of the file to / from which the script
    is stored / loaded (Script (Python) only)

Definition at line 554 of file exportimport.py.

00554 
00555     def _extractScripts( self, workflow ):
00556 
00557         """ Return a sequence of mappings describing DCWorkflow scripts.
00558 
00559         o Each mapping has the keys:
00560 
00561           'id' -- the ID of the script
00562 
00563           'meta_type' -- the title of the worklist
00564 
00565           'body' -- the text of the script (only applicable to scripts
00566             of type Script (Python))
00567 
00568           'module' -- The module from where to load the function (only
00569             applicable to External Method scripts)
00570 
00571           'function' -- The function to load from the 'module' given
00572             (Only applicable to External Method scripts)
00573 
00574           'filename' -- the name of the file to / from which the script
00575             is stored / loaded (Script (Python) only)
00576         """
00577         result = []
00578 
00579         items = workflow.scripts.objectItems()
00580         items.sort()
00581 
00582         for k, v in items:
00583 
00584             filename = _getScriptFilename( workflow.getId(), k, v.meta_type )
00585             module = ''
00586             function = ''
00587 
00588             if v.meta_type == 'External Method':
00589                 module = v.module()
00590                 function = v.function()
00591 
00592             info = { 'id'                   : k
00593                    , 'meta_type'            : v.meta_type
00594                    , 'module'               : module
00595                    , 'function'             : function
00596                    , 'filename'             : filename
00597                    }
00598 
00599             result.append( info )
00600 
00601         return result
00602 
00603 InitializeClass( WorkflowDefinitionConfigurator )
00604 

Here is the call graph for this function:

Here is the caller graph for this function:

Return a sequence of mappings for the permissions in a state.

o Each mapping has the keys:

  'name' -- the name of the permission

  'roles' -- a sequence of role IDs which have the permission

  'acquired' -- whether roles are acquired for the permission

Definition at line 375 of file exportimport.py.

00375 
00376     def _extractStatePermissions( self, state ):
00377 
00378         """ Return a sequence of mappings for the permissions in a state.
00379 
00380         o Each mapping has the keys:
00381 
00382           'name' -- the name of the permission
00383 
00384           'roles' -- a sequence of role IDs which have the permission
00385 
00386           'acquired' -- whether roles are acquired for the permission
00387         """
00388         result = []
00389         perm_roles = state.permission_roles
00390 
00391         if perm_roles:
00392             items = state.permission_roles.items()
00393             items.sort()
00394 
00395             for k, v in items:
00396 
00397                 result.append( { 'name' : k
00398                                , 'roles' : v
00399                                , 'acquired' : not isinstance( v, tuple )
00400                                } )
00401 
00402         return result
00403 

Here is the caller graph for this function:

Return a sequence of mappings describing DCWorkflow states.

o Within the workflow mapping, each 'state_info' mapping has keys:

  'id' -- the state's ID

  'title' -- the state's title

  'description' -- the state's description

  'transitions' -- a list of IDs of transitions out of the state

  'permissions' -- a list of mappings describing the permission
    map for the state

  'groups' -- a list of ( group_id, (roles,) ) tuples describing the
    group-role assignments for the state

  'variables' -- a list of mapping for the variables
    to be set when entering the state.

o Within the state_info mappings, each 'permissions' mapping
  has the keys:

  'name' -- the name of the permission

  'roles' -- a sequence of role IDs which have the permission

  'acquired' -- whether roles are acquired for the permission

o Within the state_info mappings, each 'variable' mapping
  has the keys:

  'name' -- the name of the variable

  'type' -- the type of the value (allowed values are:
    'string', 'datetime', 'bool', 'int')

  'value' -- the value to be set

Definition at line 297 of file exportimport.py.

00297 
00298     def _extractStates( self, workflow ):
00299 
00300         """ Return a sequence of mappings describing DCWorkflow states.
00301 
00302         o Within the workflow mapping, each 'state_info' mapping has keys:
00303 
00304           'id' -- the state's ID
00305 
00306           'title' -- the state's title
00307 
00308           'description' -- the state's description
00309 
00310           'transitions' -- a list of IDs of transitions out of the state
00311 
00312           'permissions' -- a list of mappings describing the permission
00313             map for the state
00314 
00315           'groups' -- a list of ( group_id, (roles,) ) tuples describing the
00316             group-role assignments for the state
00317 
00318           'variables' -- a list of mapping for the variables
00319             to be set when entering the state.
00320 
00321         o Within the state_info mappings, each 'permissions' mapping
00322           has the keys:
00323 
00324           'name' -- the name of the permission
00325 
00326           'roles' -- a sequence of role IDs which have the permission
00327 
00328           'acquired' -- whether roles are acquired for the permission
00329 
00330         o Within the state_info mappings, each 'variable' mapping
00331           has the keys:
00332 
00333           'name' -- the name of the variable
00334 
00335           'type' -- the type of the value (allowed values are:
00336                     'string', 'datetime', 'bool', 'int')
00337 
00338           'value' -- the value to be set
00339         """
00340         result = []
00341 
00342         items = workflow.states.objectItems()
00343         items.sort()
00344 
00345         for k, v in items:
00346 
00347             groups = v.group_roles and list( v.group_roles.items() ) or []
00348             groups = [ x for x in groups if x[1] ]
00349             groups.sort()
00350 
00351             variables = list( v.getVariableValues() )
00352             variables.sort()
00353 
00354             v_info = []
00355 
00356             for v_name, value in variables:
00357                 v_info.append( { 'name' : v_name
00358                                , 'type' :_guessVariableType( value )
00359                                , 'value' : value
00360                                } )
00361 
00362             info = { 'id'           : k
00363                    , 'title'        : v.title
00364                    , 'description'  : v.description
00365                    , 'transitions'  : v.transitions
00366                    , 'permissions'  : self._extractStatePermissions( v )
00367                    , 'groups'       : groups
00368                    , 'variables'    : v_info
00369                    }
00370 
00371             result.append( info )
00372 
00373         return result

Here is the call graph for this function:

Here is the caller graph for this function:

Return a sequence of mappings describing DCWorkflow transitions.

o Each mapping has the keys:

  'id' -- the transition's ID

  'title' -- the transition's ID

  'description' -- the transition's description

  'new_state_id' -- the ID of the state into which the transition
    moves an object

  'trigger_type' -- one of the following values, indicating how the
    transition is fired:

    - "AUTOMATIC" -> fired opportunistically whenever the workflow
       notices that its guard conditions permit

    - "USER" -> fired in response to user request

  'script_name' -- the ID of a script to be executed before
     the transition

  'after_script_name' -- the ID of a script to be executed after
     the transition

  'actbox_name' -- the name of the action by which the user
     triggers the transition

  'actbox_url' -- the URL of the action by which the user
     triggers the transition

  'actbox_category' -- the category of the action by which the user
     triggers the transition

  'variables' -- a list of ( id, expr ) tuples defining how variables
    are to be set during the transition

  'guard_permissions' -- a list of permissions guarding the transition

  'guard_roles' -- a list of roles guarding the transition

  'guard_groups' -- a list of groups guarding the transition

  'guard_expr' -- an expression guarding the transition

Definition at line 405 of file exportimport.py.

00405 
00406     def _extractTransitions( self, workflow ):
00407 
00408         """ Return a sequence of mappings describing DCWorkflow transitions.
00409 
00410         o Each mapping has the keys:
00411 
00412           'id' -- the transition's ID
00413 
00414           'title' -- the transition's ID
00415 
00416           'description' -- the transition's description
00417 
00418           'new_state_id' -- the ID of the state into which the transition
00419             moves an object
00420 
00421           'trigger_type' -- one of the following values, indicating how the
00422             transition is fired:
00423 
00424             - "AUTOMATIC" -> fired opportunistically whenever the workflow
00425                notices that its guard conditions permit
00426 
00427             - "USER" -> fired in response to user request
00428 
00429           'script_name' -- the ID of a script to be executed before
00430              the transition
00431 
00432           'after_script_name' -- the ID of a script to be executed after
00433              the transition
00434 
00435           'actbox_name' -- the name of the action by which the user
00436              triggers the transition
00437 
00438           'actbox_url' -- the URL of the action by which the user
00439              triggers the transition
00440 
00441           'actbox_category' -- the category of the action by which the user
00442              triggers the transition
00443 
00444           'variables' -- a list of ( id, expr ) tuples defining how variables
00445             are to be set during the transition
00446 
00447           'guard_permissions' -- a list of permissions guarding the transition
00448 
00449           'guard_roles' -- a list of roles guarding the transition
00450 
00451           'guard_groups' -- a list of groups guarding the transition
00452 
00453           'guard_expr' -- an expression guarding the transition
00454 
00455         """
00456         result = []
00457 
00458         items = workflow.transitions.objectItems()
00459         items.sort()
00460 
00461         for k, v in items:
00462 
00463             guard = v.getGuard()
00464 
00465             v_info = []
00466 
00467             for v_name, expr in v.getVariableExprs():
00468                 v_info.append( { 'name' : v_name, 'expr' : expr } )
00469 
00470             info = { 'id'                   : k
00471                    , 'title'                : v.title
00472                    , 'description'          : v.description
00473                    , 'new_state_id'         : v.new_state_id
00474                    , 'trigger_type'         : TRIGGER_TYPES[ v.trigger_type ]
00475                    , 'script_name'          : v.script_name
00476                    , 'after_script_name'    : v.after_script_name
00477                    , 'actbox_name'          : v.actbox_name
00478                    , 'actbox_url'           : v.actbox_url
00479                    , 'actbox_category'      : v.actbox_category
00480                    , 'variables'            : v_info
00481                    , 'guard_permissions'    : guard.permissions
00482                    , 'guard_roles'          : guard.roles
00483                    , 'guard_groups'         : guard.groups
00484                    , 'guard_expr'           : guard.getExprText()
00485                    }
00486 
00487             result.append( info )
00488 
00489         return result

Here is the caller graph for this function:

Return a sequence of mappings describing DCWorkflow variables.

o Keys for each mapping will include:

  'id' -- the variable's ID

  'description' -- a textual description of the variable

  'for_catalog' -- whether to catalog this variable

  'for_status' -- whether to ??? this variable (XXX)

  'update_always' -- whether to update this variable whenever
    executing a transition (xxX)

  'default_value' -- a default value for the variable (XXX)

  'default_expression' -- a TALES expression for the default value

  'guard_permissions' -- a list of permissions guarding access
    to the variable

  'guard_roles' -- a list of roles guarding access
    to the variable

  'guard_groups' -- a list of groups guarding the transition

  'guard_expr' -- an expression guarding access to the variable

Definition at line 236 of file exportimport.py.

00236 
00237     def _extractVariables( self, workflow ):
00238 
00239         """ Return a sequence of mappings describing DCWorkflow variables.
00240 
00241         o Keys for each mapping will include:
00242 
00243           'id' -- the variable's ID
00244 
00245           'description' -- a textual description of the variable
00246 
00247           'for_catalog' -- whether to catalog this variable
00248 
00249           'for_status' -- whether to ??? this variable (XXX)
00250 
00251           'update_always' -- whether to update this variable whenever
00252             executing a transition (xxX)
00253 
00254           'default_value' -- a default value for the variable (XXX)
00255 
00256           'default_expression' -- a TALES expression for the default value
00257 
00258           'guard_permissions' -- a list of permissions guarding access
00259             to the variable
00260 
00261           'guard_roles' -- a list of roles guarding access
00262             to the variable
00263 
00264           'guard_groups' -- a list of groups guarding the transition
00265 
00266           'guard_expr' -- an expression guarding access to the variable
00267         """
00268         result = []
00269 
00270         items = workflow.variables.objectItems()
00271         items.sort()
00272 
00273         for k, v in items:
00274 
00275             guard = v.getInfoGuard()
00276 
00277             default_type = _guessVariableType( v.default_value )
00278 
00279             info = { 'id'                   : k
00280                    , 'description'          : v.description
00281                    , 'for_catalog'          : bool( v.for_catalog )
00282                    , 'for_status'           : bool( v.for_status )
00283                    , 'update_always'        : bool( v.update_always )
00284                    , 'default_value'        : v.default_value
00285                    , 'default_type'         : default_type
00286                    , 'default_expr'         : v.getDefaultExprText()
00287                    , 'guard_permissions'    : guard.permissions
00288                    , 'guard_roles'          : guard.roles
00289                    , 'guard_groups'         : guard.groups
00290                    , 'guard_expr'           : guard.getExprText()
00291                    }
00292 
00293             result.append( info )
00294 
00295         return result

Here is the call graph for this function:

Here is the caller graph for this function:

Return a sequence of mappings describing DCWorkflow transitions.

o Each mapping has the keys:

  'id' -- the ID of the worklist

  'title' -- the title of the worklist

  'description' -- a textual description of the worklist

  'var_match' -- a list of ( key, value ) tuples defining
    the variables used to "activate" the worklist.

  'actbox_name' -- the name of the "action" corresponding to the
    worklist

  'actbox_url' -- the URL of the "action" corresponding to the
    worklist

  'actbox_category' -- the category of the "action" corresponding
    to the worklist

  'guard_permissions' -- a list of permissions guarding access
    to the worklist

  'guard_roles' -- a list of roles guarding access
    to the worklist

  'guard_expr' -- an expression guarding access to the worklist

Definition at line 491 of file exportimport.py.

00491 
00492     def _extractWorklists( self, workflow ):
00493 
00494         """ Return a sequence of mappings describing DCWorkflow transitions.
00495 
00496         o Each mapping has the keys:
00497 
00498           'id' -- the ID of the worklist
00499 
00500           'title' -- the title of the worklist
00501 
00502           'description' -- a textual description of the worklist
00503 
00504           'var_match' -- a list of ( key, value ) tuples defining
00505             the variables used to "activate" the worklist.
00506 
00507           'actbox_name' -- the name of the "action" corresponding to the
00508             worklist
00509 
00510           'actbox_url' -- the URL of the "action" corresponding to the
00511             worklist
00512 
00513           'actbox_category' -- the category of the "action" corresponding
00514             to the worklist
00515 
00516           'guard_permissions' -- a list of permissions guarding access
00517             to the worklist
00518 
00519           'guard_roles' -- a list of roles guarding access
00520             to the worklist
00521 
00522           'guard_expr' -- an expression guarding access to the worklist
00523 
00524         """
00525         result = []
00526 
00527         items = workflow.worklists.objectItems()
00528         items.sort()
00529 
00530         for k, v in items:
00531 
00532             guard = v.getGuard()
00533 
00534             var_match = [ ( id, v.getVarMatchText( id ) )
00535                             for id in v.getVarMatchKeys() ]
00536 
00537             info = { 'id'                   : k
00538                    , 'title'                : v.title
00539                    , 'description'          : v.description
00540                    , 'var_match'            : var_match
00541                    , 'actbox_name'          : v.actbox_name
00542                    , 'actbox_url'           : v.actbox_url
00543                    , 'actbox_category'      : v.actbox_category
00544                    , 'guard_permissions'    : guard.permissions
00545                    , 'guard_roles'          : guard.roles
00546                    , 'guard_groups'         : guard.groups
00547                    , 'guard_expr'           : guard.getExprText()
00548                    }
00549 
00550             result.append( info )
00551 
00552         return result

Here is the caller graph for this function:

Pseudo API.

Definition at line 135 of file exportimport.py.

00135 
00136     def generateWorkflowXML(self):
00137         """ Pseudo API.
00138         """
00139         return self._workflowConfig(workflow_id=self._obj.getId())

Return a mapping describing a given workflow.

o Keys in the mappings:

  'id' -- the ID of the workflow within the tool

  'meta_type' -- the workflow's meta_type

  'title' -- the workflow's title property

  'description' -- the workflow's description property

o See '_extractDCWorkflowInfo' below for keys present only for
  DCWorkflow definitions.

Definition at line 103 of file exportimport.py.

00103 
00104     def getWorkflowInfo( self, workflow_id ):
00105 
00106         """ Return a mapping describing a given workflow.
00107 
00108         o Keys in the mappings:
00109 
00110           'id' -- the ID of the workflow within the tool
00111 
00112           'meta_type' -- the workflow's meta_type
00113 
00114           'title' -- the workflow's title property
00115 
00116           'description' -- the workflow's description property
00117 
00118         o See '_extractDCWorkflowInfo' below for keys present only for
00119           DCWorkflow definitions.
00120 
00121         """
00122         workflow = self._obj
00123 
00124         workflow_info = { 'id'          : workflow_id
00125                         , 'meta_type'   : workflow.meta_type
00126                         , 'title'       : workflow.title_or_id()
00127                         , 'description' : workflow.description
00128                         }
00129 
00130         if workflow.meta_type == DCWorkflowDefinition.meta_type:
00131             self._extractDCWorkflowInfo( workflow, workflow_info )
00132 
00133         return workflow_info

Here is the call graph for this function:

Get workflow scripts information

Definition at line 141 of file exportimport.py.

00141 
00142     def getWorkflowScripts(self):
00143         """ Get workflow scripts information
00144         """
00145         return self._extractScripts(self._obj)

Here is the call graph for this function:

def DCWorkflow.exportimport.WorkflowDefinitionConfigurator.parseWorkflowXML (   self,
  xml,
  encoding = None 
)
Pseudo API.

Definition at line 147 of file exportimport.py.

00147 
00148     def parseWorkflowXML( self, xml, encoding=None ):
00149         """ Pseudo API.
00150         """
00151         dom = parseString( xml )
00152 
00153         root = dom.getElementsByTagName( 'dc-workflow' )[ 0 ]
00154 
00155         workflow_id = _getNodeAttribute( root, 'workflow_id', encoding )
00156         title = _getNodeAttribute( root, 'title', encoding )
00157         try:
00158             description = _getNodeAttribute( root, 'description', encoding )
00159         except ValueError:
00160             # Don't fail on export files that do not have the description field!
00161             description = ''
00162         state_variable = _getNodeAttribute( root, 'state_variable', encoding )
00163         initial_state = _getNodeAttribute( root, 'initial_state', encoding )
00164 
00165         states = _extractStateNodes( root, encoding )
00166         transitions = _extractTransitionNodes( root, encoding )
00167         variables = _extractVariableNodes( root, encoding )
00168         worklists = _extractWorklistNodes( root, encoding )
00169         permissions = _extractPermissionNodes( root, encoding )
00170         scripts = _extractScriptNodes( root, encoding )
00171 
00172         return ( workflow_id
00173                , title
00174                , state_variable
00175                , initial_state
00176                , states
00177                , transitions
00178                , variables
00179                , worklists
00180                , permissions
00181                , scripts
00182                , description
00183                )

Here is the call graph for this function:


Member Data Documentation

Definition at line 100 of file exportimport.py.

Initial value:
PageTemplateFile( 'wtcWorkflowExport.xml'
                                      , _xmldir
                                      , __name__='workflowConfig'
                                      )

Definition at line 185 of file exportimport.py.

Definition at line 97 of file exportimport.py.


The documentation for this class was generated from the following file: