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