Commit 5ee04678 authored by Julien Muchembled's avatar Julien Muchembled

Performance: get tools from the portal instead of relying on acquisition

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39157 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fa8d121d
...@@ -18,7 +18,6 @@ try: ...@@ -18,7 +18,6 @@ try:
from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder
except ImportError: except ImportError:
from Products.BTreeFolder2.CMFBTreeFolder import CMFBTreeFolder from Products.BTreeFolder2.CMFBTreeFolder import CMFBTreeFolder
from Products.CMFCore.utils import getToolByName
""" """
This patch tries to give only portal types that are defined This patch tries to give only portal types that are defined
...@@ -33,7 +32,7 @@ def CMFBTreeFolder_allowedContentTypes(self): ...@@ -33,7 +32,7 @@ def CMFBTreeFolder_allowedContentTypes(self):
this folder. this folder.
""" """
result = [] result = []
portal_types = getToolByName(self, 'portal_types') portal_types = self.getPortalObject().portal_types
myType = portal_types.getTypeInfo(self) myType = portal_types.getTypeInfo(self)
if myType is not None: if myType is not None:
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
from Products.CMFCore.CMFCatalogAware import CMFCatalogAware from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
from Acquisition import aq_base from Acquisition import aq_base
from Products.CMFCore.utils import getToolByName
def reindexObject(self, idxs=[], *args, **kw): def reindexObject(self, idxs=[], *args, **kw):
""" """
...@@ -31,7 +30,7 @@ def reindexObject(self, idxs=[], *args, **kw): ...@@ -31,7 +30,7 @@ def reindexObject(self, idxs=[], *args, **kw):
# Update the modification date. # Update the modification date.
if getattr(aq_base(self), 'notifyModified', None) is not None: if getattr(aq_base(self), 'notifyModified', None) is not None:
self.notifyModified() self.notifyModified()
catalog = getToolByName(self, 'portal_catalog', None) catalog = self._getCatalogTool()
if catalog is not None: if catalog is not None:
catalog.reindexObject(self, idxs=idxs, *args, **kw) catalog.reindexObject(self, idxs=idxs, *args, **kw)
......
...@@ -119,9 +119,7 @@ def DCWorkflowDefinition_listGlobalActions(self, info): ...@@ -119,9 +119,7 @@ def DCWorkflowDefinition_listGlobalActions(self, info):
''' '''
if not self.worklists: if not self.worklists:
return None # Optimization return None # Optimization
workflow_tool = getToolByName(self, 'portal_workflow') _getPortalTypeListForWorkflow = CachingMethod(self.getPortalTypeListForWorkflow,
workflow = getattr(workflow_tool, self.id)
_getPortalTypeListForWorkflow = CachingMethod(workflow.getPortalTypeListForWorkflow,
id=('_getPortalTypeListForWorkflow', self.id), id=('_getPortalTypeListForWorkflow', self.id),
cache_factory = 'erp5_ui_long') cache_factory = 'erp5_ui_long')
portal_type_list = _getPortalTypeListForWorkflow() portal_type_list = _getPortalTypeListForWorkflow()
...@@ -217,8 +215,6 @@ def DCWorkflowDefinition_getWorklistVariableMatchDict(self, info, ...@@ -217,8 +215,6 @@ def DCWorkflowDefinition_getWorklistVariableMatchDict(self, info,
""" """
if not self.worklists: if not self.worklists:
return None return None
workflow_tool = getToolByName(self, 'portal_workflow')
workflow = getattr(workflow_tool, self.id)
def getPortalTypeListForWorkflow(workflow_id): def getPortalTypeListForWorkflow(workflow_id):
workflow_tool = getToolByName(self, 'portal_workflow') workflow_tool = getToolByName(self, 'portal_workflow')
......
...@@ -448,10 +448,11 @@ def WorkflowTool_listActions(self, info=None, object=None, src__=False): ...@@ -448,10 +448,11 @@ def WorkflowTool_listActions(self, info=None, object=None, src__=False):
if a is not None: if a is not None:
worklist_dict[wf_id] = a worklist_dict[wf_id] = a
if len(worklist_dict): if worklist_dict:
is_anonymous = getToolByName(self, 'portal_membership').isAnonymousUser() portal = self.getPortalObject()
portal_url = getToolByName(self, 'portal_url')() is_anonymous = portal.portal_membership.isAnonymousUser()
portal_catalog = getToolByName(self, 'portal_catalog') portal_url = portal.portal_url()
portal_catalog = portal.portal_catalog
search_result = getattr(self, "Base_getCountFromWorklistTable", None) search_result = getattr(self, "Base_getCountFromWorklistTable", None)
use_cache = search_result is not None use_cache = search_result is not None
if use_cache: if use_cache:
......
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