Commit a47acb52 authored by Klaus Wölfel's avatar Klaus Wölfel

Fix a broken case of Worklist calculation when using security_uid columns

parent 599d5fe8
......@@ -28,6 +28,7 @@
"""
Most of the code in this file has been taken from patches/WorkflowTool.py
"""
from collections import defaultdict
from six import string_types as basestring
from AccessControl import ClassSecurityInfo, Unauthorized
from Acquisition import aq_base
......@@ -947,21 +948,17 @@ def sumCatalogResultByWorklist(grouped_worklist_dict, catalog_result):
It is better to avoid reading multiple times the catalog result from
flexibility point of view: if it must ever be changed into a cursor, this
code will keep working nicely without needing to rewind the cursor.
This code assumes that all worklists have the same set of criterion ids,
and that when a criterion id is associated with an ExclusionList it is
also true for all worklists.
"""
worklist_result_dict = {}
if len(catalog_result) > 0:
# Transtype all worklist definitions where needed
criterion_id_list = []
criterion_id_list_by_worklist_dict = defaultdict(list)
class_dict = {name: _sql_cast_dict.get(x['type'], _sql_cast_fallback)
for name, x in six.iteritems(catalog_result.data_dictionary())}
for criterion_dict in six.itervalues(grouped_worklist_dict):
for worklist_id, criterion_dict in six.iteritems(grouped_worklist_dict):
for criterion_id, criterion_value_list in six.iteritems(criterion_dict):
if type(criterion_value_list) is not ExclusionList:
criterion_id_list.append(criterion_id)
criterion_id_list_by_worklist_dict[worklist_id].append(criterion_id)
expected_class = class_dict[criterion_id]
if type(criterion_value_list[0]) is not expected_class:
criterion_dict[criterion_id] = frozenset([expected_class(x) for x in criterion_value_list])
......@@ -972,7 +969,7 @@ def sumCatalogResultByWorklist(grouped_worklist_dict, catalog_result):
result_count = int(result_line[COUNT_COLUMN_TITLE])
for worklist_id, criterion_dict in six.iteritems(grouped_worklist_dict):
is_candidate = True
for criterion_id in criterion_id_list:
for criterion_id in criterion_id_list_by_worklist_dict[worklist_id]:
criterion_value_set = criterion_dict[criterion_id]
if result_line[criterion_id] not in criterion_value_set:
is_candidate = False
......
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