Commit f387101b authored by iv's avatar iv

ERP5Workflow: provide consistent name for method returning dict

parent d0bf8ed3
...@@ -28,7 +28,7 @@ def get_obj_and_reference_list(business_field): ...@@ -28,7 +28,7 @@ def get_obj_and_reference_list(business_field):
result.append((wf, wf_id, 'workflow')) result.append((wf, wf_id, 'workflow'))
for state_id, state in wf.getStateValueList().items(): for state_id, state in wf.getStateValueList().items():
result.append((state, state_id, 'state')) result.append((state, state_id, 'state'))
for trans_id, trans in wf.getTransitionValueList().items(): for trans_id, trans in wf.getTransitionValueDict().items():
result.append((trans, trans_id, 'transition')) result.append((trans, trans_id, 'transition'))
if trans.trigger_type == 1 and trans.actbox_name: # 1 == TRIGGER_USER_ACTION if trans.trigger_type == 1 and trans.actbox_name: # 1 == TRIGGER_USER_ACTION
result.append((trans, "%s_actbox_name" % trans_id, 'action')) result.append((trans, "%s_actbox_name" % trans_id, 'action'))
......
...@@ -28,7 +28,7 @@ def get_obj_and_reference_list(business_field): ...@@ -28,7 +28,7 @@ def get_obj_and_reference_list(business_field):
result.append((wf, wf_id, 'workflow')) result.append((wf, wf_id, 'workflow'))
for state_id, state in wf.getStateValueList().items(): for state_id, state in wf.getStateValueList().items():
result.append((state, state_id, 'state')) result.append((state, state_id, 'state'))
for trans_id, trans in wf.getTransitionValueList().items(): for trans_id, trans in wf.getTransitionValueDict().items():
result.append((trans, trans_id, 'transition')) result.append((trans, trans_id, 'transition'))
if trans.trigger_type == 1 and trans.actbox_name: # 1 == TRIGGER_USER_ACTION if trans.trigger_type == 1 and trans.actbox_name: # 1 == TRIGGER_USER_ACTION
result.append((trans, "%s_actbox_name" % trans_id, 'action')) result.append((trans, "%s_actbox_name" % trans_id, 'action'))
......
...@@ -40,8 +40,7 @@ iterate(context.portal_skins) ...@@ -40,8 +40,7 @@ iterate(context.portal_skins)
# Collect python script from workflow objects. # Collect python script from workflow objects.
for workflow in context.portal_workflow.objectValues(): for workflow in context.portal_workflow.objectValues():
script_value_dict = workflow.getScriptValueList() for i in workflow.getScriptValueDict().values():
for i_id, i in script_value_dict.items():
if i.meta_type=='Script (Python)': if i.meta_type=='Script (Python)':
python_script_list.append(i) python_script_list.append(i)
...@@ -120,10 +119,10 @@ for i in context.portal_workflow.objectValues(): ...@@ -120,10 +119,10 @@ for i in context.portal_workflow.objectValues():
# also use state title as msg_id for compatibility # also use state title as msg_id for compatibility
add_message(s_title, portal_url.getRelativeContentURL(s)) add_message(s_title, portal_url.getRelativeContentURL(s))
transition_value_dict = i.getTransitionValueList() transition_value_dict = i.getTransitionValueDict()
if not transition_value_dict: if not transition_value_dict:
continue continue
for t_id, t in transition_value_dict.items(): for t in transition_value_dict.values():
if t.actbox_name: if t.actbox_name:
#adding a context in msg_id for more precise translation #adding a context in msg_id for more precise translation
msg_id = getMessageIdWithContext(t.actbox_name,'transition',i.id) msg_id = getMessageIdWithContext(t.actbox_name,'transition',i.id)
...@@ -136,7 +135,7 @@ for i in context.portal_workflow.objectValues(): ...@@ -136,7 +135,7 @@ for i in context.portal_workflow.objectValues():
add_message(msg_id, portal_url.getRelativeContentURL(t)) add_message(msg_id, portal_url.getRelativeContentURL(t))
# also use transition title as msg_id for compatibility # also use transition title as msg_id for compatibility
add_message(t.title, portal_url.getRelativeContentURL(t)) add_message(t.title, portal_url.getRelativeContentURL(t))
for worklist_id, worklist in i.getWorklistValueList().items(): for worklist in i.getWorklistValueDict().values():
add_message(worklist.actbox_name, portal_url.getRelativeContentURL(worklist)) add_message(worklist.actbox_name, portal_url.getRelativeContentURL(worklist))
......
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
portal_workflow = context.getPortalObject().portal_workflow portal_workflow = context.getPortalObject().portal_workflow
workflow = getattr(portal_workflow, workflow_id) workflow = getattr(portal_workflow, workflow_id)
worklist = workflow.getWorklistValueList()[worklist_id] worklist = workflow.getWorklistValueDict()[worklist_id]
roles = worklist.getGuard().getRolesText().split(';') roles = worklist.getGuard().getRolesText().split(';')
return roles return roles
...@@ -14,7 +14,7 @@ except: ...@@ -14,7 +14,7 @@ except:
return {} return {}
# If this is a worklist action, read the worklist definition # If this is a worklist action, read the worklist definition
worklist = workflow.getWorklistValueList()[action['worklist_id']] worklist = workflow.getWorklistValueDict()[action['worklist_id']]
for varkey in worklist.getVarMatchKeys(): for varkey in worklist.getVarMatchKeys():
kw[varkey] = worklist.getVarMatch(varkey) kw[varkey] = worklist.getVarMatch(varkey)
......
...@@ -310,8 +310,7 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=0): ...@@ -310,8 +310,7 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=0):
# Workflows. # Workflows.
for wf in self.portal_workflow.objectValues(): for wf in self.portal_workflow.objectValues():
# Transitions. # Transitions.
Transition_value_dict = wf.getTransitionValueList() for id, transition in wf.getTransitionValueDict().items():
for id, transition in Transition_value_dict.items():
text = transition.actbox_url text = transition.actbox_url
for info in info_list: for info in info_list:
if info.regexp.search(text) is not None: if info.regexp.search(text) is not None:
...@@ -323,8 +322,7 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=0): ...@@ -323,8 +322,7 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=0):
transition.actbox_url = text transition.actbox_url = text
break break
# Worklists. # Worklists.
worklist_value_dict = wf.getWorklistValueList() for id, worklist in wf.getWorklistValueDict().items():
for id, worklist in worklist_value_dict.items():
text = worklist.actbox_url text = worklist.actbox_url
for info in info_list: for info in info_list:
if info.regexp.search(text) is not None: if info.regexp.search(text) is not None:
...@@ -336,8 +334,7 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=0): ...@@ -336,8 +334,7 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=0):
worklist.actbox_url = text worklist.actbox_url = text
break break
# Scripts. # Scripts.
script_value_dict = wf.getScriptValueList() for id, script in wf.getScriptValueDict().items():
for id, script in script_value_dict.items():
text = script.manage_FTPget() text = script.manage_FTPget()
name_list = [] name_list = []
for info in info_list: for info in info_list:
......
...@@ -352,7 +352,7 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject): ...@@ -352,7 +352,7 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
def getReference(self): def getReference(self):
return self.id return self.id
def getTransitionValueList(self): def getTransitionValueDict(self):
if self.interactions is not None: if self.interactions is not None:
return self.interactions return self.interactions
return None return None
......
...@@ -41,7 +41,7 @@ for history_name in ['history', 'building_history', 'installation_history']: ...@@ -41,7 +41,7 @@ for history_name in ['history', 'building_history', 'installation_history']:
workflow = getattr(portal_workflow, workflow_id) workflow = getattr(portal_workflow, workflow_id)
wf_state_var = workflow.getStateVariable() wf_state_var = workflow.getStateVariable()
wf_states = workflow.getStateValueList() wf_states = workflow.getStateValueList()
wf_transitions = workflow.getTransitionValueList() wf_transitions = workflow.getTransitionValueDict()
next_serial = None next_serial = None
previous_obj = None previous_obj = None
......
...@@ -116,7 +116,7 @@ class WorkflowSecurityConfiguratorItem(ConfiguratorItemMixin, XMLObject): ...@@ -116,7 +116,7 @@ class WorkflowSecurityConfiguratorItem(ConfiguratorItemMixin, XMLObject):
transition_list = table_dict['transition'] transition_list = table_dict['transition']
for transition_conf in transition_list: for transition_conf in transition_list:
transition_id = transition_conf.pop('transition') transition_id = transition_conf.pop('transition')
transition = workflow.getTransitionValueList()[transition_id] transition = workflow.getTransitionValueDict()[transition_id]
guard = transition.getGuard() guard = transition.getGuard()
role_list = [x.capitalize() for x in transition_conf.keys()] role_list = [x.capitalize() for x in transition_conf.keys()]
role_string = ';'.join(role_list) role_string = ';'.join(role_list)
......
...@@ -519,10 +519,10 @@ def initializePortalTypeDynamicWorkflowMethods(ptype_klass, portal_workflow): ...@@ -519,10 +519,10 @@ def initializePortalTypeDynamicWorkflowMethods(ptype_klass, portal_workflow):
Permissions.AccessContentsInformation) Permissions.AccessContentsInformation)
storage = workflow_dict storage = workflow_dict
transitions = wf.getTransitionValueList() transitions = wf.getTransitionValueDict()
elif wf_type in ['InteractionWorkflowDefinition', 'Interaction Workflow']: elif wf_type in ['InteractionWorkflowDefinition', 'Interaction Workflow']:
storage = interaction_workflow_dict storage = interaction_workflow_dict
transitions = wf.getTransitionValueList() transitions = wf.getTransitionValueDict()
else: else:
continue continue
......
...@@ -112,7 +112,7 @@ class TypesTool(TypeProvider): ...@@ -112,7 +112,7 @@ class TypesTool(TypeProvider):
pass pass
try: try:
script = self.getPortalObject().portal_workflow \ script = self.getPortalObject().portal_workflow \
.dynamic_class_generation_interaction_workflow.getScriptValueList() \ .dynamic_class_generation_interaction_workflow.getScriptValueDict() \
.DynamicClassGeneration_resetDynamicDocuments .DynamicClassGeneration_resetDynamicDocuments
new = '.resetDynamicDocumentsOnceAtTransactionBoundary(' new = '.resetDynamicDocumentsOnceAtTransactionBoundary('
if new not in script._body: if new not in script._body:
......
...@@ -810,7 +810,7 @@ def DCWorkflowDefinition_getStateIdList(self): ...@@ -810,7 +810,7 @@ def DCWorkflowDefinition_getStateIdList(self):
if self.states is not None: if self.states is not None:
return self.states.objectIds() return self.states.objectIds()
return [] return []
def DCWorkflowDefinition_getTransitionValueList(self): def DCWorkflowDefinition_getTransitionValueDict(self):
if self.transitions is not None: if self.transitions is not None:
return self.transitions return self.transitions
else: else:
...@@ -819,7 +819,7 @@ def DCWorkflowDefinition_getTransitionIdList(self): ...@@ -819,7 +819,7 @@ def DCWorkflowDefinition_getTransitionIdList(self):
if self.transitions is not None: if self.transitions is not None:
return self.transitions.objectIds() return self.transitions.objectIds()
return [] return []
def DCWorkflowDefinition_getWorklistValueList(self): def DCWorkflowDefinition_getWorklistValueDict(self):
if self.worklists is not None: if self.worklists is not None:
return self.worklists return self.worklists
return {} return {}
...@@ -829,7 +829,7 @@ def DCWorkflowDefinition_getWorklistIdList(self): ...@@ -829,7 +829,7 @@ def DCWorkflowDefinition_getWorklistIdList(self):
return [] return []
def DCWorkflowDefinition_propertyIds(self): def DCWorkflowDefinition_propertyIds(self):
return sorted(self.__dict__.keys()) return sorted(self.__dict__.keys())
def DCWorkflowDefinition_getScriptValueList(self): def DCWorkflowDefinition_getScriptValueDict(self):
if self.scripts is not None: if self.scripts is not None:
return self.scripts return self.scripts
return {} return {}
...@@ -1086,9 +1086,9 @@ DCWorkflowDefinition.notifyBefore = DCWorkflowDefinition_notifyBefore ...@@ -1086,9 +1086,9 @@ DCWorkflowDefinition.notifyBefore = DCWorkflowDefinition_notifyBefore
DCWorkflowDefinition.notifySuccess = DCWorkflowDefinition_notifySuccess DCWorkflowDefinition.notifySuccess = DCWorkflowDefinition_notifySuccess
DCWorkflowDefinition.getVariableValueList = DCWorkflowDefinition_getVariableValueList DCWorkflowDefinition.getVariableValueList = DCWorkflowDefinition_getVariableValueList
DCWorkflowDefinition.getStateValueList = DCWorkflowDefinition_getStateValueList DCWorkflowDefinition.getStateValueList = DCWorkflowDefinition_getStateValueList
DCWorkflowDefinition.getTransitionValueList = DCWorkflowDefinition_getTransitionValueList DCWorkflowDefinition.getTransitionValueDict = DCWorkflowDefinition_getTransitionValueDict
DCWorkflowDefinition.getWorklistValueList = DCWorkflowDefinition_getWorklistValueList DCWorkflowDefinition.getWorklistValueDict = DCWorkflowDefinition_getWorklistValueDict
DCWorkflowDefinition.getScriptValueList = DCWorkflowDefinition_getScriptValueList DCWorkflowDefinition.getScriptValueDict = DCWorkflowDefinition_getScriptValueDict
DCWorkflowDefinition.getVariableIdList = DCWorkflowDefinition_getVariableIdList DCWorkflowDefinition.getVariableIdList = DCWorkflowDefinition_getVariableIdList
DCWorkflowDefinition.getStateIdList = DCWorkflowDefinition_getStateIdList DCWorkflowDefinition.getStateIdList = DCWorkflowDefinition_getStateIdList
DCWorkflowDefinition.getTransitionIdList = DCWorkflowDefinition_getTransitionIdList DCWorkflowDefinition.getTransitionIdList = DCWorkflowDefinition_getTransitionIdList
......
...@@ -36,7 +36,7 @@ def _createExprContext(sci): ...@@ -36,7 +36,7 @@ def _createExprContext(sci):
''' '''
ob = sci.object ob = sci.object
wf = sci.workflow wf = sci.workflow
scripts = wf.getScriptValueList() script_dict = wf.getScriptValueDict()
container = aq_parent(aq_inner(ob)) container = aq_parent(aq_inner(ob))
data = { data = {
'here': ob, 'here': ob,
...@@ -53,7 +53,7 @@ def _createExprContext(sci): ...@@ -53,7 +53,7 @@ def _createExprContext(sci):
'status': sci.status, 'status': sci.status,
'kwargs': sci.kwargs, 'kwargs': sci.kwargs,
'workflow': wf, 'workflow': wf,
'scripts': scripts, 'scripts': script_dict,
} }
return getEngine().getContext(data) return getEngine().getContext(data)
......
...@@ -219,7 +219,7 @@ class SecurityTestCase(ERP5TypeTestCase): ...@@ -219,7 +219,7 @@ class SecurityTestCase(ERP5TypeTestCase):
continue continue
for wf_transition_id in wf._getWorkflowStateOf( for wf_transition_id in wf._getWorkflowStateOf(
document).getTransitions(): document).getTransitions():
wf_transition = wf.getTransitionValueList()[wf_transition_id] wf_transition = wf.getTransitionValueDict()[wf_transition_id]
if wf_transition.trigger_type == TRIGGER_USER_ACTION: if wf_transition.trigger_type == TRIGGER_USER_ACTION:
workflow_transitions_description.append( workflow_transitions_description.append(
"%s%s[%s]: %s" % ( "%s%s[%s]: %s" % (
......
...@@ -187,15 +187,15 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow): ...@@ -187,15 +187,15 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
def _getWorkflowStateOf(self, ob, id_only=0): def _getWorkflowStateOf(self, ob, id_only=0):
return None return None
security.declarePrivate('getScriptValueList') security.declarePrivate('getScriptValueDict')
def getScriptValueList(self): def getScriptValueDict(self):
scripts = {} scripts = {}
for script in self.objectValues(portal_type='Workflow Script'): for script in self.objectValues(portal_type='Workflow Script'):
scripts[script.getReference()] = script scripts[script.getReference()] = script
return scripts return scripts
security.declarePrivate('getTransitionValueList') security.declarePrivate('getTransitionValueDict')
def getTransitionValueList(self): def getTransitionValueDict(self):
interaction_dict = {} interaction_dict = {}
for tdef in self.objectValues(portal_type="Interaction"): for tdef in self.objectValues(portal_type="Interaction"):
interaction_dict[tdef.getReference()] = tdef interaction_dict[tdef.getReference()] = tdef
......
...@@ -359,7 +359,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -359,7 +359,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
security_manager = getSecurityManager() security_manager = getSecurityManager()
workflow_id = self.getId() workflow_id = self.getId()
workflow_title = self.getTitle() workflow_title = self.getTitle()
for worklist_id, worklist_definition in self.getWorklistValueList().items(): for worklist_id, worklist_definition in self.getWorklistValueDict().items():
action_box_name = worklist_definition.getActboxName() action_box_name = worklist_definition.getActboxName()
guard = worklist_definition.getGuard() guard = worklist_definition.getGuard()
if action_box_name: if action_box_name:
...@@ -502,7 +502,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -502,7 +502,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
id_list.append(ob.getReference()) id_list.append(ob.getReference())
return id_list return id_list
def getWorklistValueList(self): def getWorklistValueDict(self):
worklist_dict = {} worklist_dict = {}
for qdef in self.objectValues(portal_type="Worklist"): for qdef in self.objectValues(portal_type="Worklist"):
worklist_dict[qdef.getReference()] = qdef worklist_dict[qdef.getReference()] = qdef
...@@ -514,7 +514,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -514,7 +514,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
id_list.append(ob.getReference()) id_list.append(ob.getReference())
return id_list return id_list
def getTransitionValueList(self): def getTransitionValueDict(self):
transition_dict = {} transition_dict = {}
for tdef in self.objectValues(portal_type="Transition"): for tdef in self.objectValues(portal_type="Transition"):
transition_dict[tdef.getReference()] = tdef transition_dict[tdef.getReference()] = tdef
...@@ -526,7 +526,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -526,7 +526,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
id_list.append(ob.getReference()) id_list.append(ob.getReference())
return id_list return id_list
def getScriptValueList(self): def getScriptValueDict(self):
scripts = {} scripts = {}
for script in self.objectValues(portal_type='Workflow Script'): for script in self.objectValues(portal_type='Workflow Script'):
scripts[script.getReference()] = script scripts[script.getReference()] = script
...@@ -741,7 +741,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -741,7 +741,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
raise WorkflowException, 'Object is in an undefined state' raise WorkflowException, 'Object is in an undefined state'
if method_id not in sdef.getTransitionIdList(): if method_id not in sdef.getTransitionIdList():
raise Unauthorized(method_id) raise Unauthorized(method_id)
tdef = self.getTransitionValueList().get(method_id, None) tdef = self.getTransitionValueDict().get(method_id, None)
if tdef is None or tdef.getTriggerType() != TRIGGER_WORKFLOW_METHOD: if tdef is None or tdef.getTriggerType() != TRIGGER_WORKFLOW_METHOD:
raise WorkflowException, ( raise WorkflowException, (
'Transition %s is not triggered by a workflow method' 'Transition %s is not triggered by a workflow method'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment