Commit 4fbb8f94 authored by iv's avatar iv

ERP5Workflow: idem, change getScriptValueDict and getWorklistValueDict

parent 4e77594b
......@@ -134,7 +134,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 in i.getWorklistValueDict().values():
for worklist in i.getWorklistValueList():
add_message(worklist.actbox_name, portal_url.getRelativeContentURL(worklist))
......
......@@ -322,19 +322,19 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=0):
transition.actbox_url = text
break
# Worklists.
for id, worklist in wf.getWorklistValueDict().items():
for worklist in wf.getWorklistValueList():
text = worklist.actbox_url
for info in info_list:
if info.regexp.search(text) is not None:
text = info.regexp.sub(info.new_name, text)
line = 'Worklist %s of %s is modified for %s' % (id, 'portal_workflow/' + wf.id, info.name)
line = 'Worklist %s of %s is modified for %s' % (worklist.getReference(), 'portal_workflow/' + wf.id, info.name)
LOG('fixSkinNames', 0, line)
msg += '%s\n' % line
if not dry_run:
worklist.actbox_url = text
break
# Scripts.
for id, script in wf.getScriptValueDict().items():
for script in wf.getScriptValueList():
text = script.manage_FTPget()
name_list = []
for info in info_list:
......@@ -342,7 +342,7 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=0):
text = info.regexp.sub(info.new_name, text)
name_list.append(info.name)
if len(name_list) > 0:
line = 'Script %s of %s is modified for %s' % (id, 'portal_workflow/' + wf.id, ', '.join(name_list))
line = 'Script %s of %s is modified for %s' % (script.getReference(), 'portal_workflow/' + wf.id, ', '.join(name_list))
LOG('fixSkinNames', 0, line)
msg += '%s\n' % line
if not dry_run:
......
......@@ -111,8 +111,11 @@ class TypesTool(TypeProvider):
except AttributeError:
pass
try:
script = self.getPortalObject().portal_workflow \
.dynamic_class_generation_interaction_workflow.getScriptValueDict() \
worflow_tool = self.getPortalObject().portal_workflow
workflow = workflow_tool.dynamic_class_generation_interaction_workflow
script_dict = {script.getReference(): script
for script in workflow.getScriptValueList()}
script = script_dict\
.DynamicClassGeneration_resetDynamicDocuments
new = '.resetDynamicDocumentsOnceAtTransactionBoundary('
if new not in script._body:
......
......@@ -827,20 +827,20 @@ def DCWorkflowDefinition_getTransitionIdList(self):
if self.transitions is not None:
return self.transitions.objectIds()
return []
def DCWorkflowDefinition_getWorklistValueDict(self):
def DCWorkflowDefinition_getWorklistValueList(self):
if self.worklists is not None:
return self.worklists
return {}
return self.worklists.values()
return []
def DCWorkflowDefinition_getWorklistIdList(self):
if self.worklists is not None:
return self.worklists.objectIds()
return []
def DCWorkflowDefinition_propertyIds(self):
return sorted(self.__dict__.keys())
def DCWorkflowDefinition_getScriptValueDict(self):
def DCWorkflowDefinition_getScriptValueList(self):
if self.scripts is not None:
return self.scripts
return {}
return self.scripts.values()
return []
def StateDefinition_getDestinationIdList(self):
return self.transitions
def DCWorkflowDefinition_getPortalType(self):
......@@ -1097,8 +1097,8 @@ DCWorkflowDefinition.getStateValueById = DCWorkflowDefinition_getStateValueById
DCWorkflowDefinition.getStateValueList = DCWorkflowDefinition_getStateValueList
DCWorkflowDefinition.getTransitionValueById = DCWorkflowDefinition_getTransitionValueById
DCWorkflowDefinition.getTransitionValueList = DCWorkflowDefinition_getTransitionValueList
DCWorkflowDefinition.getWorklistValueDict = DCWorkflowDefinition_getWorklistValueDict
DCWorkflowDefinition.getScriptValueDict = DCWorkflowDefinition_getScriptValueDict
DCWorkflowDefinition.getWorklistValueList = DCWorkflowDefinition_getWorklistValueList
DCWorkflowDefinition.getScriptValueList = DCWorkflowDefinition_getScriptValueList
DCWorkflowDefinition.getVariableIdList = DCWorkflowDefinition_getVariableIdList
DCWorkflowDefinition.getStateIdList = DCWorkflowDefinition_getStateIdList
DCWorkflowDefinition.getTransitionIdList = DCWorkflowDefinition_getTransitionIdList
......
......@@ -36,7 +36,8 @@ def _createExprContext(sci):
'''
ob = sci.object
wf = sci.workflow
script_dict = wf.getScriptValueDict()
script_dict = {script.getReference(): script
for script in wf.getScriptValueList()}
container = aq_parent(aq_inner(ob))
data = {
'here': ob,
......
......@@ -187,12 +187,9 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
def _getWorkflowStateOf(self, ob, id_only=0):
return None
security.declarePrivate('getScriptValueDict')
def getScriptValueDict(self):
scripts = {}
for script in self.objectValues(portal_type='Workflow Script'):
scripts[script.getReference()] = script
return scripts
security.declarePrivate('getScriptValueList')
def getScriptValueList(self):
return self.objectValues(portal_type='Workflow Script')
security.declarePrivate('getTransitionValueById')
def getTransitionValueById(self, transition_id):
......
......@@ -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.getWorklistValueDict().items():
for worklist_definition in self.getWorklistValueList():
action_box_name = worklist_definition.getActboxName()
guard = worklist_definition.getGuard()
if action_box_name:
......@@ -401,6 +401,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
fmt_data._push({k: ('&%s:list=' % k).join(v) for\
k, v in variable_match.iteritems()})
worklist_id = worklist_definition.getReference()
variable_match[WORKLIST_METADATA_KEY] = {
'format_data': fmt_data,
'worklist_title': action_box_name,
......@@ -502,11 +503,8 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
id_list.append(ob.getReference())
return id_list
def getWorklistValueDict(self):
worklist_dict = {}
for qdef in self.objectValues(portal_type="Worklist"):
worklist_dict[qdef.getReference()] = qdef
return worklist_dict
def getWorklistValueList(self):
return self.objectValues(portal_type="Worklist")
def getWorklistIdList():
id_list = []
......@@ -522,16 +520,11 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
return self.objectValues(portal_type="Transition")
def getTransitionIdList(self):
id_list = []
for ob in self.objectValues(portal_type="Transition"):
id_list.append(ob.getReference())
return id_list
return [ob.getReference() for ob
in self.objectValues(portal_type="Transition")]
def getScriptValueDict(self):
scripts = {}
for script in self.objectValues(portal_type='Workflow Script'):
scripts[script.getReference()] = script
return scripts
def getScriptValueList(self):
return self.objectValues(portal_type='Workflow Script')
def notifyWorkflowMethod(self, ob, transition_list, args=None, kw=None):
""" Execute workflow methods.
......
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