Commit a162f0a5 authored by Julien Muchembled's avatar Julien Muchembled

Remove a few uses of 'apply' builtin function

- 'apply' causes a break in cProfile results
- 'apply' is deprecated (removed in Python 3)
parent 117bee10
......@@ -179,7 +179,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
return filt
def _buildQuery(self, spec, filter, kw):
return apply( ContentFilter, (), self._buildFilter(spec, filter, kw) )
return ContentFilter(**self._buildFilter(spec, filter, kw))
# Category accessors
security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryList')
......
......@@ -203,7 +203,7 @@ class WorkflowMethod(Method):
# Try to return immediately if there are no transition to invoke
if not candidate_transition_item_list:
return apply(self.__dict__['_m'], (instance,) + args, kw)
return self.__dict__['_m'](instance, *args, **kw)
# Prepare a list of transitions which should be invoked.
# This list is based on the results of isWorkflowMethodSupported.
......@@ -240,7 +240,7 @@ class WorkflowMethod(Method):
wf[wf_id].notifyBefore(instance, transition_list, args=args, kw=kw)
# Compute expected result
result = apply(self.__dict__['_m'], (instance,) + args, kw)
result = self.__dict__['_m'](instance, *args, **kw)
# Change the state of statefull workflows
for wf_id, transition_list in valid_transition_item_list:
......
......@@ -25,7 +25,6 @@ from AccessControl import ClassSecurityInfo, getSecurityManager
from Products.ERP5Type.Globals import InitializeClass
from Acquisition import aq_base, aq_parent
from zLOG import LOG, INFO, ERROR
from string import find
from cStringIO import StringIO
from Products.ERP5Type import Permissions
import sys
......@@ -208,14 +207,15 @@ def DA__call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw):
security=getSecurityManager()
security.addContext(self)
try:
try: query=apply(self.template, (p,), argdata)
query = self.template(p, **argdata)
except TypeError, msg:
msg = str(msg)
if find(msg,'client') >= 0:
raise NameError("'client' may not be used as an " +
if 'client' in msg:
raise NameError("'client' may not be used as an "
"argument name in this context")
else: raise
finally: security.removeContext(self)
raise
finally:
security.removeContext(self)
if src__: return query
......
......@@ -150,7 +150,6 @@ def DCWorkflowDefinition_listGlobalActions(self, info):
dict = {}
# Patch for ERP5 by JP Smets in order
# to implement worklists and search of local roles
searchres_len = 0
var_match_keys = qdef.getVarMatchKeys()
if var_match_keys:
# Check the catalog for items in the worklist.
......@@ -175,9 +174,11 @@ def DCWorkflowDefinition_listGlobalActions(self, info):
dict['local_roles'] = guard.roles
# Patch to use ZSQLCatalog and get high speed
# LOG("PatchedDCWorkflowDefinition", 0, dict)
searchres_len = int(apply(catalog.countResults, (), dict)[0][0])
if searchres_len == 0:
searchres_len = catalog.countResults(**dict)[0][0]
if not searchres_len:
continue
else:
searchres_len = 0
if fmt_data is None:
fmt_data = TemplateDict()
fmt_data._push(info)
......
......@@ -1088,7 +1088,7 @@ class ZCatalog(Folder, Persistent, Implicit):
"""
catalog = self.getSQLCatalog(sql_catalog_id)
if catalog is not None:
return apply(catalog.searchResults, (REQUEST, ), kw)
return catalog.searchResults(REQUEST, **kw)
return []
__call__=searchResults
......@@ -1100,7 +1100,7 @@ class ZCatalog(Folder, Persistent, Implicit):
"""
catalog = self.getSQLCatalog(sql_catalog_id)
if catalog is not None:
return apply(catalog.countResults, (REQUEST, ), kw)
return catalog.countResults(REQUEST, **kw)
return []
## this stuff is so the find machinery works
......
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