Commit cc60f03a authored by Jérome Perrin's avatar Jérome Perrin

*: stop using deprecated getWorkflowById

This was deprectated because we don't have get*ById for other modules
and tools, we just use OFS API. This should also be slightly faster
because one less method call (and one less call to warning)
parent 32e04c8a
Pipeline #20572 failed with stage
......@@ -87,7 +87,7 @@ def WorkflowTool_listActionParameterList(self):
for action in action_list:
if (action['workflow_id'] not in workflow_dict):
workflow = self.getWorkflowById(action['workflow_id'])
workflow = self._getOb(action['workflow_id'], None)
if workflow is not None:
workflow_dict[action['workflow_id']] = workflow.getWorklistVariableMatchDict(info, check_guard=False)
......
......@@ -5569,8 +5569,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
Returns the current state in building
"""
portal_workflow = getToolByName(self, 'portal_workflow')
wf = portal_workflow.getWorkflowById(
'business_template_building_workflow')
wf = portal_workflow._getOb('business_template_building_workflow')
return wf._getWorkflowStateOf(self, id_only=id_only )
security.declareProtected(Permissions.AccessContentsInformation,
......@@ -5580,8 +5579,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
Returns the current state in installation
"""
portal_workflow = getToolByName(self.getPortalObject(), 'portal_workflow')
wf = portal_workflow.getWorkflowById(
'business_template_installation_workflow')
wf = portal_workflow._getOb('business_template_installation_workflow')
return wf._getWorkflowStateOf(self, id_only=id_only )
security.declareProtected(Permissions.AccessContentsInformation, 'toxml')
......
......@@ -126,7 +126,7 @@ def getDocumentGroupByWorkflowStateList(self, form_id='', **kw):
for (ptype, workflow_id, _), (doc, document_count) in\
workflow_state_dict.iteritems():
workflow = wf_tool.getWorkflowById(workflow_id)
workflow = wf_tool._getOb(workflow_id)
state_var = workflow.getStateVariable()
translated_workflow_state_title = doc.getProperty(
'translated_%s_title' % state_var)
......@@ -185,7 +185,7 @@ def getWorkflowActionDocumentList(self, **kw):
selection_params['uid'] = selection_uid_list
workflow_id, action = listbox_selection['workflow_action'].split('/')[:2]
workflow = wtool.getWorkflowById(workflow_id)
workflow = wtool._getOb(workflow_id)
for doc in selection_tool.callSelectionFor(selection_name, params=selection_params):
doc = doc.getObject()
action_list = [ai for ai in
......
......@@ -56,7 +56,7 @@ class Getter(BaseGetter):
def __call__(self, instance):
portal_workflow = instance.getPortalObject().portal_workflow
wf = portal_workflow.getWorkflowById(self._key)
wf = portal_workflow._getOb(self._key)
return wf._getWorkflowStateOf(instance, id_only=1)
psyco.bind(__call__)
......@@ -81,7 +81,7 @@ class TitleGetter(BaseGetter):
def __call__(self, instance):
portal_workflow = instance.getPortalObject().portal_workflow
wf = portal_workflow.getWorkflowById(self._key)
wf = portal_workflow._getOb(self._key)
return wf._getWorkflowStateOf(instance).title
psyco.bind(__call__)
......@@ -92,7 +92,7 @@ class TranslatedGetter(Getter):
def __call__(self, instance):
portal = instance.getPortalObject()
wf = portal.portal_workflow.getWorkflowById(self._key)
wf = portal.portal_workflow._getOb(self._key)
state_id = wf._getWorkflowStateOf(instance, id_only=1)
warn('Translated workflow state getters, such as %s are deprecated' %
self._id, DeprecationWarning)
......@@ -109,7 +109,7 @@ class TranslatedTitleGetter(TitleGetter):
portal = instance.getPortalObject()
localizer = portal.Localizer
wf_id = self._key
wf = portal.portal_workflow.getWorkflowById(wf_id)
wf = portal.portal_workflow._getOb(wf_id)
selected_language = localizer.get_selected_language()
state_title = wf._getWorkflowStateOf(instance).title
msg_id = '%s [state in %s]' % (state_title, wf_id)
......
......@@ -3373,7 +3373,7 @@ class Base(
There's no check that the document is actually chained to the workflow,
it's caller responsability to perform this check.
"""
workflow = self.portal_workflow.getWorkflowById(wf_id)
workflow = self.portal_workflow._getOb(wf_id, None)
if workflow is not None:
changed = workflow.updateRoleMappingsFor(self)
if changed:
......
......@@ -99,7 +99,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
raise WorkflowException('No workflow provides the destination state %r'\
% state_id)
else:
workflow = self.getWorkflowById(wf_id)
workflow = self._getOb(wf_id, None)
if workflow is None:
raise WorkflowException('Requested workflow definition not found.')
......@@ -194,7 +194,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
Message(u"No workflow provides the '${action_id}' action.",
mapping={'action_id': action}))
else:
workflow = self.getWorkflowById(workflow_id)
workflow = self._getOb(workflow_id, None)
if workflow is None:
raise WorkflowException(Message(u'Requested workflow not found.'))
......@@ -334,7 +334,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
worklist_dict = {}
wf_ids = self.objectIds()
for wf_id in wf_ids:
wf = self.getWorkflowById(wf_id)
wf = self._getOb(wf_id, None)
if wf is not None:
a = wf.getWorklistVariableMatchDict(info, check_guard=False)
if a is not None:
......
......@@ -160,7 +160,7 @@ def canDoActionFor(self, ob, action, wf_id=None, guard_kw={}):
if wf_id is None:
workflow_list = self.getWorkflowValueListFor(ob) or ()
else:
workflow = self.getWorkflowById(wf_id)
workflow = self._getOb(wf_id, None)
if workflow:
workflow_list = (workflow,)
else:
......
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