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