Commit d43bd352 authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5Type.patches.WorfklowTool: Stop using *_expression catalog arguments.

Preserve compatibility with in-zodb worklist cache code, but do not use
*_expression when calling catalog.
parent d8fe72b5
...@@ -493,8 +493,8 @@ def WorkflowTool_listActions(self, info=None, object=None, src__=False): ...@@ -493,8 +493,8 @@ def WorkflowTool_listActions(self, info=None, object=None, src__=False):
sql_catalog.getSQLCatalogSecurityUidGroupsColumnsDict() sql_catalog.getSQLCatalogSecurityUidGroupsColumnsDict()
getSecurityUidDictAndRoleColumnDict = \ getSecurityUidDictAndRoleColumnDict = \
portal_catalog.getSecurityUidDictAndRoleColumnDict portal_catalog.getSecurityUidDictAndRoleColumnDict
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:
ignored_security_column_id_set = self._getWorklistIgnoredSecurityColumnSet() ignored_security_column_id_set = self._getWorklistIgnoredSecurityColumnSet()
ignored_security_uid_parameter_set = {x ignored_security_uid_parameter_set = {x
...@@ -512,12 +512,26 @@ def WorkflowTool_listActions(self, info=None, object=None, src__=False): ...@@ -512,12 +512,26 @@ def WorkflowTool_listActions(self, info=None, object=None, src__=False):
ignored_security_uid_parameter_set: ignored_security_uid_parameter_set:
security_uid_dict.pop(ignored_security_uid_parameter) security_uid_dict.pop(ignored_security_uid_parameter)
return security_uid_dict, role_column_dict, local_role_column_dict return security_uid_dict, role_column_dict, local_role_column_dict
select_expression_prefix = 'sum(`%s`) as %s' % (COUNT_COLUMN_TITLE, COUNT_COLUMN_TITLE) count_column_expression = 'sum(`%s`)' % (COUNT_COLUMN_TITLE, )
# Prevent catalog from trying to join # Prevent catalog from trying to join
getQuery = SimpleQuery getQuery = SimpleQuery
# BBB
def search_result(select_dict, group_by, query, limit, src__):
select_item_list = []
for alias, expression in select_dict.iteritems():
if expression is None:
expression = alias
select_item_list.append('%s AS %s' % (expression, alias))
return search_result_(
select_expression=','.join(select_item_list),
group_by_expression=','.join(group_by),
query=query,
limit=limit,
src__=src__,
)
else: else:
search_result = portal_catalog.unrestrictedSearchResults search_result = portal_catalog.unrestrictedSearchResults
select_expression_prefix = 'count(*) as %s' % (COUNT_COLUMN_TITLE, ) count_column_expression = 'count(*)'
# Let catalog join as needed # Let catalog join as needed
getQuery = lambda comparison_operator=None, **kw: AutoQuery( getQuery = lambda comparison_operator=None, **kw: AutoQuery(
operator=comparison_operator, operator=comparison_operator,
...@@ -544,18 +558,15 @@ def WorkflowTool_listActions(self, info=None, object=None, src__=False): ...@@ -544,18 +558,15 @@ def WorkflowTool_listActions(self, info=None, object=None, src__=False):
getQuery=getQuery, getQuery=getQuery,
grouped_worklist_dict=grouped_worklist_dict, grouped_worklist_dict=grouped_worklist_dict,
) )
group_by_expression = ', '.join(total_criterion_id_list) group_by = total_criterion_id_list
assert COUNT_COLUMN_TITLE not in total_criterion_id_list assert COUNT_COLUMN_TITLE not in total_criterion_id_list
# If required mapping method is not present on the query, assume it select_dict = dict.fromkeys(total_criterion_id_list)
# handles column mapping properly, and build a bare select select_dict[COUNT_COLUMN_TITLE] = count_column_expression
# expression.
select_expression = select_expression_prefix + ', ' \
+ group_by_expression
catalog_brain_result = [] catalog_brain_result = []
try: try:
catalog_brain_result = search_result( catalog_brain_result = search_result(
select_expression=select_expression, select_dict=select_dict,
group_by_expression=group_by_expression, group_by=group_by,
query=query, query=query,
limit=None, limit=None,
src__=src__) src__=src__)
...@@ -684,14 +695,16 @@ def WorkflowTool_refreshWorklistCache(self): ...@@ -684,14 +695,16 @@ def WorkflowTool_refreshWorklistCache(self):
for security_column_id in security_column_id_set: for security_column_id in security_column_id_set:
assert security_column_id not in total_criterion_id_list assert security_column_id not in total_criterion_id_list
total_criterion_id_list.append(security_column_id) total_criterion_id_list.append(security_column_id)
group_by_expression = ', '.join(total_criterion_id_list) group_by = total_criterion_id_list
assert COUNT_COLUMN_TITLE not in total_criterion_id_list assert COUNT_COLUMN_TITLE not in total_criterion_id_list
select_expression = 'count(*) as %s, %s' % (COUNT_COLUMN_TITLE, select_dict = dict.fromkeys(total_criterion_id_list)
group_by_expression) select_dict[COUNT_COLUMN_TITLE] = 'count(*)'
search_result_kw = {'select_expression': select_expression, search_result_kw = {
'group_by_expression': group_by_expression, 'select_dict': select_dict,
'query': query, 'group_by': group_by,
'limit': None} 'query': query,
'limit': None,
}
#LOG('refreshWorklistCache', WARNING, 'Using query: %s' % \ #LOG('refreshWorklistCache', WARNING, 'Using query: %s' % \
# (search_result(src__=1, **search_result_kw), )) # (search_result(src__=1, **search_result_kw), ))
catalog_brain_result = search_result(**search_result_kw) catalog_brain_result = search_result(**search_result_kw)
......
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