Commit e1c6bea4 authored by iv's avatar iv

ERP5Workflow: fix more uncorrectly named method (changed List to Dict)

parent f64bbdd2
...@@ -26,7 +26,7 @@ def get_obj_and_reference_list(business_field): ...@@ -26,7 +26,7 @@ def get_obj_and_reference_list(business_field):
wf = getattr(portal_workflow, wf_id) wf = getattr(portal_workflow, wf_id)
if getattr(wf, "interactions", marker) is marker: # only way to make sure it is not an interaction workflow ? if getattr(wf, "interactions", marker) is marker: # only way to make sure it is not an interaction workflow ?
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.getStateValueDict().items():
result.append((state, state_id, 'state')) result.append((state, state_id, 'state'))
for trans_id, trans in wf.getTransitionValueDict().items(): for trans_id, trans in wf.getTransitionValueDict().items():
result.append((trans, trans_id, 'transition')) result.append((trans, trans_id, 'transition'))
......
...@@ -26,7 +26,7 @@ def get_obj_and_reference_list(business_field): ...@@ -26,7 +26,7 @@ def get_obj_and_reference_list(business_field):
wf = getattr(portal_workflow, wf_id) wf = getattr(portal_workflow, wf_id)
if getattr(wf, "interactions", marker) is marker: # only way to make sure it is not an interaction workflow ? if getattr(wf, "interactions", marker) is marker: # only way to make sure it is not an interaction workflow ?
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.getStateValueDict().items():
result.append((state, state_id, 'state')) result.append((state, state_id, 'state'))
for trans_id, trans in wf.getTransitionValueDict().items(): for trans_id, trans in wf.getTransitionValueDict().items():
result.append((trans, trans_id, 'transition')) result.append((trans, trans_id, 'transition'))
......
...@@ -107,7 +107,7 @@ for i in page_template_list: ...@@ -107,7 +107,7 @@ for i in page_template_list:
s_title_list = [] s_title_list = []
for i in context.portal_workflow.objectValues(): for i in context.portal_workflow.objectValues():
add_message(i.title_or_id(), portal_url.getRelativeContentURL(i)) add_message(i.title_or_id(), portal_url.getRelativeContentURL(i))
state_value_dict = i.getStateValueList() state_value_dict = i.getStateValueDict()
if not state_value_dict: if not state_value_dict:
continue continue
for s_id, s in state_value_dict.items(): for s_id, s in state_value_dict.items():
......
...@@ -65,7 +65,7 @@ if position_graph:\n ...@@ -65,7 +65,7 @@ if position_graph:\n
\n \n
def getWorkflowGraph(workflow):\n def getWorkflowGraph(workflow):\n
graph = dict(node=dict(), edge=dict())\n graph = dict(node=dict(), edge=dict())\n
for state_id, state in workflow.getStateValueList().iteritems():\n for state_id, state in workflow.getStateValueDict().iteritems():\n
is_initial_state = state.getId() == workflow.getSourceId()\n is_initial_state = state.getId() == workflow.getSourceId()\n
transition_id_list = []\n transition_id_list = []\n
graph[\'node\'][state.getId()] = dict(\n graph[\'node\'][state.getId()] = dict(\n
......
...@@ -773,7 +773,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin): ...@@ -773,7 +773,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
def getStateList(group): def getStateList(group):
state_dict = {} state_dict = {}
for wf in self.portal_workflow.objectValues(): for wf in self.portal_workflow.objectValues():
state_list = wf.getStateValueList() state_list = wf.getStateValueDict()
for state_id in state_list: for state_id in state_list:
state = state_list[state_id] state = state_list[state_id]
if group in getattr(state, 'type_list', ()): if group in getattr(state, 'type_list', ()):
...@@ -1300,8 +1300,8 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin): ...@@ -1300,8 +1300,8 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
def getStateList(): def getStateList():
state_dict = {} state_dict = {}
for wf in self.portal_workflow.objectValues(): for wf in self.portal_workflow.objectValues():
if wf.getVariableValueList() and wf.getStateVariable() == 'simulation_state': if wf.getVariableValueDict() and wf.getStateVariable() == 'simulation_state':
state_list = wf.getStateValueList() state_list = wf.getStateValueDict()
for state_id in state_list: for state_id in state_list:
state = state_list[state_id] state = state_list[state_id]
if getattr(state, 'type_list', None): if getattr(state, 'type_list', None):
......
...@@ -40,7 +40,7 @@ for history_name in ['history', 'building_history', 'installation_history']: ...@@ -40,7 +40,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.getStateValueDict()
wf_transitions = workflow.getTransitionValueDict() wf_transitions = workflow.getTransitionValueDict()
next_serial = None next_serial = None
......
...@@ -11,7 +11,7 @@ state_dict = {} ...@@ -11,7 +11,7 @@ state_dict = {}
item_list = [] item_list = []
for workflow_id in workflow_id_list: for workflow_id in workflow_id_list:
workflow = getToolByName(context, 'portal_workflow')[workflow_id] workflow = getToolByName(context, 'portal_workflow')[workflow_id]
for state_id, state in workflow.getStateValueList().items(): for state_id, state in workflow.getStateValueDict().items():
if state.title and state_id!='deleted': if state.title and state_id!='deleted':
if not state_dict.has_key(state_id): if not state_dict.has_key(state_id):
# we hide states without titles # we hide states without titles
......
...@@ -183,7 +183,7 @@ for folder in context.portal_skins.objectValues(spec=('Folder',)): ...@@ -183,7 +183,7 @@ for folder in context.portal_skins.objectValues(spec=('Folder',)):
for wf in context.portal_workflow.objectValues(): for wf in context.portal_workflow.objectValues():
# Test workflow states # Test workflow states
wf_states = wf.getStateValueList() wf_states = wf.getStateValueDict()
message = '' message = ''
if wf_states not in (None, (), [], ''): if wf_states not in (None, (), [], ''):
for state_id in wf_states.keys(): for state_id in wf_states.keys():
......
...@@ -34,15 +34,15 @@ for portal_type in portal_type: ...@@ -34,15 +34,15 @@ for portal_type in portal_type:
workflow = workflow_tool[workflow_id] workflow = workflow_tool[workflow_id]
# skip interaction workflows or workflows with only one state (such as edit_workflow) # skip interaction workflows or workflows with only one state (such as edit_workflow)
if workflow.getStateValueList() is None or len(workflow.getStateIdList()) <= 1: if workflow.getStateValueDict() is None or len(workflow.getStateIdList()) <= 1:
continue continue
# skip workflows using another state variable # skip workflows using another state variable
if state_var not in (None, workflow.getStateVariable()): if state_var not in (None, workflow.getStateVariable()):
continue continue
for state_id in workflow.getStateValueList(): for state_id in workflow.getStateValueDict():
state = workflow.getStateValueList().get(state_id) state = workflow.getStateValueDict().get(state_id)
if state_id in state_set: if state_id in state_set:
continue continue
state_set.add(state_id) state_set.add(state_id)
......
...@@ -32,8 +32,8 @@ for portal_type in portal_type_list: ...@@ -32,8 +32,8 @@ for portal_type in portal_type_list:
if wf is None: if wf is None:
continue continue
state_var = wf.getStateVariable() state_var = wf.getStateVariable()
if wf.getStateValueList(): if wf.getStateValueDict():
state_value_list = wf.getStateValueList() state_value_list = wf.getStateValueDict()
for state_ref, state in state_value_list.items(): for state_ref, state in state_value_list.items():
for lang in supported_languages: for lang in supported_languages:
key = (lang, pt_id, state_var, state_ref) key = (lang, pt_id, state_var, state_ref)
......
...@@ -12,7 +12,7 @@ for portal_type in context.allowedContentTypes(): ...@@ -12,7 +12,7 @@ for portal_type in context.allowedContentTypes():
portal_type_id = portal_type.getId() portal_type_id = portal_type.getId()
portal_type_translated_title_dict[portal_type_id] = translateString(portal_type.getTitle()) portal_type_translated_title_dict[portal_type_id] = translateString(portal_type.getTitle())
for workflow in getWorkflowsFor(portal_type_id): for workflow in getWorkflowsFor(portal_type_id):
state_container = workflow.getStateValueList() state_container = workflow.getStateValueDict()
if state_container is not None and len(state_container) > 1: if state_container is not None and len(state_container) > 1:
state_var = workflow.getStateVariable() state_var = workflow.getStateVariable()
if state_var is None: if state_var is None:
......
...@@ -2742,7 +2742,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -2742,7 +2742,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
Make sure that changing workflow state after delivered changes Make sure that changing workflow state after delivered changes
records in stock table. records in stock table.
""" """
delivered_state = self.portal.portal_workflow.inventory_workflow.getStateValueList()['delivered'] delivered_state = self.portal.portal_workflow.inventory_workflow.getStateValueDict()['delivered']
delivered_state.addPossibleTransition('cancel') delivered_state.addPossibleTransition('cancel')
self.commit() self.commit()
......
...@@ -88,7 +88,7 @@ class WorkflowSecurityConfiguratorItem(ConfiguratorItemMixin, XMLObject): ...@@ -88,7 +88,7 @@ class WorkflowSecurityConfiguratorItem(ConfiguratorItemMixin, XMLObject):
state_list = table_dict['state'] state_list = table_dict['state']
for state_config in state_list: for state_config in state_list:
state_id = state_config.pop('state') state_id = state_config.pop('state')
state = workflow.getStateValueList()[state_id] state = workflow.getStateValueDict()[state_id]
# Clean the state matrix # Clean the state matrix
for permission in permission_list: for permission in permission_list:
state.setPermission(permission, 0, []) state.setPermission(permission, 0, [])
......
...@@ -328,8 +328,8 @@ def getSearchDialog(self, REQUEST=None): ...@@ -328,8 +328,8 @@ def getSearchDialog(self, REQUEST=None):
continue continue
workflow_set.add(state_var) workflow_set.add(state_var)
if workflow.getStateValueList() is None or \ if workflow.getStateValueDict() is None or \
len(workflow.getStateValueList()) <= 1: len(workflow.getStateValueDict()) <= 1:
continue continue
field_id = 'your_%s' % state_var field_id = 'your_%s' % state_var
...@@ -340,7 +340,7 @@ def getSearchDialog(self, REQUEST=None): ...@@ -340,7 +340,7 @@ def getSearchDialog(self, REQUEST=None):
form_id='Base_viewDialogFieldLibrary', form_id='Base_viewDialogFieldLibrary',
field_id='your_category_list')) field_id='your_category_list'))
items = sorted([(translateString(x.title), x.id) for x_ref, x items = sorted([(translateString(x.title), x.id) for x_ref, x
in workflow.getStateValueList().items()], in workflow.getStateValueDict().items()],
key=lambda x:str(x[0])) key=lambda x:str(x[0]))
field._surcharged_edit( field._surcharged_edit(
dict(title=translateString(workflow.title), dict(title=translateString(workflow.title),
......
...@@ -792,7 +792,7 @@ def DCWorkflowDefinition_notifySuccess(self, ob, transition_list, result, args=N ...@@ -792,7 +792,7 @@ def DCWorkflowDefinition_notifySuccess(self, ob, transition_list, result, args=N
pass pass
# following 15 patches are required for the new workflow tool compatibility. # following 15 patches are required for the new workflow tool compatibility.
def DCWorkflowDefinition_getVariableValueList(self): def DCWorkflowDefinition_getVariableValueDict(self):
if self.variables is not None: if self.variables is not None:
return self.variables return self.variables
return {} return {}
...@@ -802,7 +802,7 @@ def DCWorkflowDefinition_getVariableIdList(self): ...@@ -802,7 +802,7 @@ def DCWorkflowDefinition_getVariableIdList(self):
return [] return []
def DCWorkflowDefinition_getStateVariable(self): def DCWorkflowDefinition_getStateVariable(self):
return self.state_var return self.state_var
def DCWorkflowDefinition_getStateValueList(self): def DCWorkflowDefinition_getStateValueDict(self):
if self.states is not None: if self.states is not None:
return self.states return self.states
return {} return {}
...@@ -1084,8 +1084,8 @@ DCWorkflowDefinition.getSourceValue = DCWorkflowDefinition_getSourceValue ...@@ -1084,8 +1084,8 @@ DCWorkflowDefinition.getSourceValue = DCWorkflowDefinition_getSourceValue
DCWorkflowDefinition.notifyWorkflowMethod = DCWorkflowDefinition_notifyWorkflowMethod DCWorkflowDefinition.notifyWorkflowMethod = DCWorkflowDefinition_notifyWorkflowMethod
DCWorkflowDefinition.notifyBefore = DCWorkflowDefinition_notifyBefore DCWorkflowDefinition.notifyBefore = DCWorkflowDefinition_notifyBefore
DCWorkflowDefinition.notifySuccess = DCWorkflowDefinition_notifySuccess DCWorkflowDefinition.notifySuccess = DCWorkflowDefinition_notifySuccess
DCWorkflowDefinition.getVariableValueList = DCWorkflowDefinition_getVariableValueList DCWorkflowDefinition.getVariableValueDict = DCWorkflowDefinition_getVariableValueDict
DCWorkflowDefinition.getStateValueList = DCWorkflowDefinition_getStateValueList DCWorkflowDefinition.getStateValueDict = DCWorkflowDefinition_getStateValueDict
DCWorkflowDefinition.getTransitionValueDict = DCWorkflowDefinition_getTransitionValueDict DCWorkflowDefinition.getTransitionValueDict = DCWorkflowDefinition_getTransitionValueDict
DCWorkflowDefinition.getWorklistValueDict = DCWorkflowDefinition_getWorklistValueDict DCWorkflowDefinition.getWorklistValueDict = DCWorkflowDefinition_getWorklistValueDict
DCWorkflowDefinition.getScriptValueDict = DCWorkflowDefinition_getScriptValueDict DCWorkflowDefinition.getScriptValueDict = DCWorkflowDefinition_getScriptValueDict
......
...@@ -970,7 +970,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -970,7 +970,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.getWorkflowTool().getWorkflowValueListFor('Person')) self.getWorkflowTool().getWorkflowValueListFor('Person'))
self.assertEqual('validation_state', wf.getStateVariable()) self.assertEqual('validation_state', wf.getStateVariable())
initial_state = wf.getSourceValue() initial_state = wf.getSourceValue()
other_state = wf.getStateValueList()['validated'] other_state = wf.getStateValueDict()['validated']
self.assertTrue(hasattr(person, 'getValidationState')) self.assertTrue(hasattr(person, 'getValidationState'))
self.assertTrue(hasattr(person, 'getValidationStateTitle')) self.assertTrue(hasattr(person, 'getValidationStateTitle'))
......
...@@ -118,7 +118,7 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow): ...@@ -118,7 +118,7 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
''' '''
Returns a true value if the given info name is supported. Returns a true value if the given info name is supported.
''' '''
vdef = self.getVariableValueList().get(name, None) vdef = self.getVariableValueDict().get(name, None)
if vdef is None: if vdef is None:
return 0 return 0
return 1 return 1
...@@ -367,7 +367,7 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow): ...@@ -367,7 +367,7 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
return 1 return 1
return 0 return 0
def getStateValueList(self): def getStateValueDict(self):
return {} return {}
def showAsXML(self, root=None): def showAsXML(self, root=None):
......
...@@ -196,7 +196,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -196,7 +196,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
''' '''
if name == self.getStateVariable(): if name == self.getStateVariable():
return 1 return 1
vdef = self.getVariableValueList().get(name, None) vdef = self.getVariableValueDict().get(name, None)
if vdef is None: if vdef is None:
return 0 return 0
return 1 return 1
...@@ -424,7 +424,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -424,7 +424,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
''' '''
if name == self.getStateVariable(): if name == self.getStateVariable():
return self._getWorkflowStateOf(ob, 1) return self._getWorkflowStateOf(ob, 1)
vdef = self.getVariableValueList()[name] vdef = self.getVariableValueDict()[name]
if vdef.getInfoGuard() is not None and not vdef.getInfoGuard().check( if vdef.getInfoGuard() is not None and not vdef.getInfoGuard().check(
getSecurityManager(), self, ob): getSecurityManager(), self, ob):
return default return default
...@@ -478,7 +478,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -478,7 +478,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
else: else:
return state return state
def getVariableValueList(self): def getVariableValueDict(self):
variable_dict = {} variable_dict = {}
for vdef in self.objectValues(portal_type="Variable"): for vdef in self.objectValues(portal_type="Variable"):
variable_dict[vdef.getReference()] = vdef variable_dict[vdef.getReference()] = vdef
...@@ -490,7 +490,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -490,7 +490,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
id_list.append(ob.getReference()) id_list.append(ob.getReference())
return id_list return id_list
def getStateValueList(self): def getStateValueDict(self):
state_dict = {} state_dict = {}
for sdef in self.objectValues(portal_type="State"): for sdef in self.objectValues(portal_type="State"):
state_dict[sdef.getReference()] = sdef state_dict[sdef.getReference()] = sdef
...@@ -1050,13 +1050,13 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -1050,13 +1050,13 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
raise WorkflowException, ('Destination state undefined: ' + new_state_id) raise WorkflowException, ('Destination state undefined: ' + new_state_id)
# Update variables. # Update variables.
state_values = self.getVariableValueList() state_values = self.getVariableValueDict()
if state_values is None: if state_values is None:
state_values = {} state_values = {}
tdef_exprs = {} tdef_exprs = {}
status = {} status = {}
for id, vdef in self.getVariableValueList().items(): for id, vdef in self.getVariableValueDict().items():
if vdef.getForStatus() == 0: if vdef.getForStatus() == 0:
continue continue
expr = None expr = None
...@@ -1118,7 +1118,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -1118,7 +1118,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
# Always provide the state variable. # Always provide the state variable.
state_var = self.getStateVariable() state_var = self.getStateVariable()
status = self.getCurrentStatusDict(ob) status = self.getCurrentStatusDict(ob)
for vdef_ref, vdef in self.getVariableValueList().iteritems(): for vdef_ref, vdef in self.getVariableValueDict().iteritems():
if vdef.getForCatalog(): if vdef.getForCatalog():
default_expr = vdef.getDefaultExpr() default_expr = vdef.getDefaultExpr()
if status.has_key(vdef_ref): if status.has_key(vdef_ref):
......
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