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