Commit 77a1b9ce authored by Vincent Pelletier's avatar Vincent Pelletier

WIP all: Stop using *_expression catalog arguments.

parent b1d92322
...@@ -47,15 +47,13 @@ elif to_date is not None: ...@@ -47,15 +47,13 @@ elif to_date is not None:
'range': 'max', 'range': 'max',
'query': to_date, 'query': to_date,
} }
select_expression = {'date' : 'DATE_FORMAT(creation_date, "%s")'%sql_format, 'portal_type' : None}
group_by = ['DATE_FORMAT(creation_date, "%s")' % sql_format, 'portal_type']
# count number of object created by the user for each type of document # count number of object created by the user for each type of document
reference = kw.get('person_reference_list', context.Person_getUserId()) reference = kw.get('person_reference_list', context.Person_getUserId())
result_list = context.portal_catalog.countResults(select_expression=select_expression, result_list = context.portal_catalog.countResults(select_dict={'date': 'DATE_FORMAT(creation_date, "%s")' % sql_format, 'portal_type': None},
portal_type=portal_type_list,limit=None, portal_type=portal_type_list,limit=None,
owner=reference, owner=reference,
group_by_expression=group_by, group_by=['DATE_FORMAT(creation_date, "%s")' % sql_format, 'portal_type'],
**count_kw) **count_kw)
# build result dict per portal_type then period # build result dict per portal_type then period
......
...@@ -33,11 +33,11 @@ if context.Person_getUserId() not in (None, ""): ...@@ -33,11 +33,11 @@ if context.Person_getUserId() not in (None, ""):
selection_columns = [('document_type', "Document Type")] selection_columns = [('document_type', "Document Type")]
if from_date is None: if from_date is None:
# get the minimum creation date in catalog # get the minimum creation date in catalog
select_expression = "MIN(creation_date)" from_date = context.portal_catalog(
group_by = "creation_date" select_list=['creation_date'],
from_date = DateTime(context.portal_catalog(select_expression=select_expression, sort_on=[['creation_date', 'ASC']],
group_by_expression=group_by, limit=1,
limit=1)[0][2]) )[0].creation_date
# get period list between given date # get period list between given date
interval_list_dict = getIntervalListBetweenDates(from_date=from_date, to_date=to_date, interval_list_dict = getIntervalListBetweenDates(from_date=from_date, to_date=to_date,
keys={'year':aggregation_level=="year", keys={'year':aggregation_level=="year",
......
...@@ -47,14 +47,12 @@ elif to_date is not None: ...@@ -47,14 +47,12 @@ elif to_date is not None:
'range': 'ngt', 'range': 'ngt',
'query': to_date, 'query': to_date,
} }
select_expression = {'date' : 'DATE_FORMAT(creation_date, "%s")'%sql_format}
group_by = ['DATE_FORMAT(creation_date, "%s")' % sql_format,]
# count number of object created by the user for each type of document # count number of object created by the user for each type of document
result_list = context.portal_catalog.countResults(select_expression=select_expression, result_list = context.portal_catalog.countResults(select_dict={'date': 'DATE_FORMAT(creation_date, "%s")' % sql_format},
portal_type=portal_type_list,limit=None, portal_type=portal_type_list,limit=None,
owner=context.Person_getUserId(), owner=context.Person_getUserId(),
group_by_expression=group_by, group_by=['DATE_FORMAT(creation_date, "%s")' % sql_format],
**count_kw) **count_kw)
# build result dict per portal_type then period # build result dict per portal_type then period
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
- if requested, filters result so that only the user's docs are returned - if requested, filters result so that only the user's docs are returned
- if requested, filters result to return only the newest versions - if requested, filters result to return only the newest versions
""" """
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
portal = context.getPortalObject() portal = context.getPortalObject()
query_kw = {} query_kw = {}
...@@ -49,25 +50,21 @@ for key in ('reference', 'version', 'language',): ...@@ -49,25 +50,21 @@ for key in ('reference', 'version', 'language',):
if value is not None: if value is not None:
query_kw[key] = value query_kw[key] = value
where_expression_list = [] query_list = []
creation_from = parsed_search_string.get('creation_from', None) creation_from = parsed_search_string.get('creation_from', None)
creation_to = parsed_search_string.get('creation_to', None) creation_to = parsed_search_string.get('creation_to', None)
modification_from = parsed_search_string.get('modification_from', None) modification_from = parsed_search_string.get('modification_from', None)
modification_to = parsed_search_string.get('modification_to', None) modification_to = parsed_search_string.get('modification_to', None)
if creation_from: if creation_from:
where_expression_list.append('catalog.creation_date >= "%s"' \ query_list.append(SimpleQuery(creation_date=creation_from.strftime('>=' + date_format)))
%creation_from.strftime(date_format))
if creation_to: if creation_to:
where_expression_list.append('catalog.creation_date <= "%s"' \ query_list.append(SimpleQuery(creation_date=creation_to.strftime('<=' + date_format)))
%creation_to.strftime(date_format))
if modification_from: if modification_from:
where_expression_list.append('catalog.modification_date >= "%s"' \ query_list.append(SimpleQuery(modification_date=modification_from.strftime('>=' + date_format)))
%modification_from.strftime(date_format))
if modification_to: if modification_to:
where_expression_list.append('catalog.modification_date <= "%s"' \ query_list.append(SimpleQuery(modification_date=modification_to.strftime('<=' + date_format)))
%modification_to.strftime(date_format)) if query_list:
if len(where_expression_list): query_kw['query'] = ComplexQuery(query_list, logical_operator='and')
query_kw['where_expression'] = ' AND '.join(where_expression_list)
if parsed_search_string.get('mine', None) is not None: if parsed_search_string.get('mine', None) is not None:
# user wants only his documents # user wants only his documents
......
...@@ -20,8 +20,8 @@ def getAvailableSubjectList(subject_list=(), container_uid=None): ...@@ -20,8 +20,8 @@ def getAvailableSubjectList(subject_list=(), container_uid=None):
""" """
#log("In getAvailableSubjectList with container: %s subject_list: %s" % (container_uid, subject_list)) #log("In getAvailableSubjectList with container: %s subject_list: %s" % (container_uid, subject_list))
kw = dict(subject="!=", kw = dict(subject="!=",
select_expression="subject.subject", select_list=["subject.subject"],
group_by_expression="subject.subject", group_by=["subject.subject"],
#src__=1 #src__=1
) )
if container_uid: kw['parent_uid'] = container_uid if container_uid: kw['parent_uid'] = container_uid
......
...@@ -4,7 +4,7 @@ if depth == 0: ...@@ -4,7 +4,7 @@ if depth == 0:
task_uid_list = context.portal_selections.getSelectionUidList(context=context, selection_name='task_module_selection') task_uid_list = context.portal_selections.getSelectionUidList(context=context, selection_name='task_module_selection')
person_result = context.portal_catalog(portal_type=["Person",], person_result = context.portal_catalog(portal_type=["Person",],
source_related_uid=task_uid_list, source_related_uid=task_uid_list,
select_expression='relative_url, id, title', select_list=['relative_url', 'id', 'title'],
sort_on = (('title','ascending'),)) sort_on = (('title','ascending'),))
person_dict = {} person_dict = {}
......
...@@ -6,11 +6,11 @@ def Task_getRelatedSourceProject(depth, parent_relative_url=None): ...@@ -6,11 +6,11 @@ def Task_getRelatedSourceProject(depth, parent_relative_url=None):
task_uid_list = context.portal_selections.getSelectionUidList(context=context, selection_name='task_module_selection') task_uid_list = context.portal_selections.getSelectionUidList(context=context, selection_name='task_module_selection')
project_result = context.portal_catalog(portal_type=["Project", "Project Line"], project_result = context.portal_catalog(portal_type=["Project", "Project Line"],
source_project_related_uid=task_uid_list, source_project_related_uid=task_uid_list,
select_expression='portal_type, relative_url, id, title', select_list=['portal_type', 'relative_url', 'id', 'title'],
sort_on = (('title','ascending'),)) sort_on = (('title','ascending'),))
else: else:
project_result = context.portal_catalog(portal_type=["Project Line", "Project Milestones"], project_result = context.portal_catalog(portal_type=["Project Line", "Project Milestones"],
select_expression='portal_type, relative_url, id, title', select_list=['portal_type', 'relative_url', 'id', 'title'],
parent_relative_url=parent_relative_url, parent_relative_url=parent_relative_url,
sort_on = (('title','ascending'),)) sort_on = (('title','ascending'),))
# use a dict to store catalog result # use a dict to store catalog result
......
...@@ -4,7 +4,7 @@ if depth == 0: ...@@ -4,7 +4,7 @@ if depth == 0:
task_uid_list = context.portal_selections.getSelectionUidList(context=context, selection_name='task_report_module_selection') task_uid_list = context.portal_selections.getSelectionUidList(context=context, selection_name='task_report_module_selection')
person_result = context.portal_catalog(portal_type=["Person",], person_result = context.portal_catalog(portal_type=["Person",],
source_related_uid=task_uid_list, source_related_uid=task_uid_list,
select_expression='portal_type, relative_url, id, title', select_list=['portal_type', 'relative_url', 'id', 'title'],
sort_on = (('title','ascending'),)) sort_on = (('title','ascending'),))
person_dict = {} person_dict = {}
person_list = [] person_list = []
......
...@@ -6,11 +6,11 @@ def Task_getRelatedSourceProject(depth, parent_relative_url=None): ...@@ -6,11 +6,11 @@ def Task_getRelatedSourceProject(depth, parent_relative_url=None):
task_uid_list = context.portal_selections.getSelectionUidList(context=context, selection_name='task_report_module_selection') task_uid_list = context.portal_selections.getSelectionUidList(context=context, selection_name='task_report_module_selection')
project_result = context.portal_catalog(portal_type=["Project", "Project Line"], project_result = context.portal_catalog(portal_type=["Project", "Project Line"],
source_project_related_uid=task_uid_list, source_project_related_uid=task_uid_list,
select_expression='portal_type, relative_url, id, title', select_list=['portal_type', 'relative_url', 'id', 'title'],
sort_on = (('title','ascending'),)) sort_on = (('title','ascending'),))
else: else:
project_result = context.portal_catalog(portal_type=["Project Line", "Project Milestones"], project_result = context.portal_catalog(portal_type=["Project Line", "Project Milestones"],
select_expression='portal_type, relative_url, id, title', select_list=['portal_type', 'relative_url', 'id', 'title'],
parent_relative_url=parent_relative_url, parent_relative_url=parent_relative_url,
sort_on = (('title','ascending'),)) sort_on = (('title','ascending'),))
# use a dict to store catalog result # use a dict to store catalog result
......
...@@ -79,18 +79,18 @@ else: ...@@ -79,18 +79,18 @@ else:
Query(birth_date = [DateTime(person_start_date.year(), 1, 1), DateTime(person_start_date.year(), 12, 31),],range = 'minmax'), Query(birth_date = [DateTime(person_start_date.year(), 1, 1), DateTime(person_start_date.year(), 12, 31),],range = 'minmax'),
operator = "AND"), operator = "AND"),
operator = "OR") operator = "OR")
select_expression = \
"""((title ="%s"))AS result_order
""" % (person_title)
#select_expression = \ #select_expression = \
#"""((title ="%s") + (start_date ="%s") + (birthplace_city ="%s"))AS result_order #"""((title ="%s") + (start_date ="%s") + (birthplace_city ="%s"))AS result_order
#""" % (person_title, person_start_date, person_birthplace) #""" % (person_title, person_start_date, person_birthplace)
candidate_list = context.portal_catalog(portal_type = 'Person', candidate_list = sorted(
query = query, context.portal_catalog(
select_expression = select_expression, portal_type='Person',
sort_on = (('result_order', 'DESC', 'int'),), query=query,
select_expression_key = 'result_order') select_list=['title'],
),
key=lambda x: x.title == person_title
)
for candidate in candidate_list: for candidate in candidate_list:
candidate_first_name = candidate.getFirstName() candidate_first_name = candidate.getFirstName()
......
...@@ -292,7 +292,7 @@ class OscommerceERP5NodeConduit(TioSafeBaseConduit): ...@@ -292,7 +292,7 @@ class OscommerceERP5NodeConduit(TioSafeBaseConduit):
address_list = document.searchFolder( address_list = document.searchFolder(
portal_type='Address', portal_type='Address',
sort_on=(['id', 'ASC'],), sort_on=(['id', 'ASC'],),
where_expression='id != "default_address"', id='!=default_address',
) )
try: try:
address = address_list[address_index].getObject() address = address_list[address_index].getObject()
...@@ -385,7 +385,7 @@ class OscommerceERP5NodeConduit(TioSafeBaseConduit): ...@@ -385,7 +385,7 @@ class OscommerceERP5NodeConduit(TioSafeBaseConduit):
address_list = document.searchFolder( address_list = document.searchFolder(
portal_type='Address', portal_type='Address',
sort_on=(['id', 'ASC'], ), sort_on=(['id', 'ASC'], ),
where_expression='id != "default_address"', id='!=default_address',
) )
address_id = address_list[address_index].getId() address_id = address_list[address_index].getId()
try: try:
......
...@@ -37,18 +37,15 @@ if from_date is None: ...@@ -37,18 +37,15 @@ if from_date is None:
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery
kw = {"delivery.start_date" : None, "key":"DefaultKey"} kw = {"delivery.start_date" : None, "key":"DefaultKey"}
q = NegatedQuery(Query(**kw)) q = NegatedQuery(Query(**kw))
select_expression = "MIN(delivery.start_date)"
group_by = "delivery.start_date"
from_date = DateTime() from_date = DateTime()
result_list = context.portal_catalog( result_list = context.portal_catalog(
select_expression=select_expression, select_dict={'start_date': 'delivery.start_date'},
group_by_expression=group_by,
simulation_state=simulation_state, simulation_state=simulation_state,
portal_type=doc_portal_type, portal_type=doc_portal_type,
query=q, query=q,
limit=1) limit=1)
if result_list: if result_list:
from_date = DateTime(result_list[0][2]) from_date = DateTime(result_list[0].start_date)
# get period list between given date # get period list between given date
......
...@@ -19,7 +19,7 @@ def buildIndex(language=None): ...@@ -19,7 +19,7 @@ def buildIndex(language=None):
from Products.ZSQLCatalog.SQLCatalog import NegatedQuery, Query from Products.ZSQLCatalog.SQLCatalog import NegatedQuery, Query
# Retrieve the different subjects in the catalog # Retrieve the different subjects in the catalog
subject_list = context.searchResults( subject_list = context.searchResults(
select_expression='subject, reference', select_list=['subject', 'reference'],
query=NegatedQuery(Query(subject=None)), query=NegatedQuery(Query(subject=None)),
language=language or '', language=language or '',
sort_on=(('subject', 'ascending'), ('title', 'ascending')), sort_on=(('subject', 'ascending'), ('title', 'ascending')),
......
...@@ -808,7 +808,7 @@ class SimulationTool(BaseTool): ...@@ -808,7 +808,7 @@ class SimulationTool(BaseTool):
if where_expression != '': if where_expression != '':
add_kw['where_expression'] = where_expression add_kw['where_expression'] = where_expression
add_kw['predicate_category.uid'] = '!=NULL' add_kw['predicate_category.uid'] = '!=NULL'
add_kw['group_by_expression'] = 'uid' add_kw['group_by'] = ['uid']
add_query = self.portal_catalog(**add_kw) add_query = self.portal_catalog(**add_kw)
uid_list = [] uid_list = []
for line in add_query: for line in add_query:
......
...@@ -264,7 +264,7 @@ class TestSaleSupply(TestSupplyMixin, SubcontentReindexingWrapper, ...@@ -264,7 +264,7 @@ class TestSaleSupply(TestSupplyMixin, SubcontentReindexingWrapper,
kw = {} kw = {}
kw['predicate.uid'] = supply_line.getUid() kw['predicate.uid'] = supply_line.getUid()
kw['select_expression'] = 'predicate.start_date_range_min' kw['select_list'] = ['predicate.start_date_range_min']
# check supply line in predicate table # check supply line in predicate table
result = self.catalog_tool(**kw) result = self.catalog_tool(**kw)
......
...@@ -576,8 +576,8 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -576,8 +576,8 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
security_uid_dict = {None: [x.security_uid for x in \ security_uid_dict = {None: [x.security_uid for x in \
self.unrestrictedSearchResults( self.unrestrictedSearchResults(
allowedRolesAndUsers=allowedRolesAndUsers, allowedRolesAndUsers=allowedRolesAndUsers,
select_expression="security_uid", select_list=["security_uid"],
group_by_expression="security_uid")] } group_by=["security_uid"])] }
else: else:
# XXX: What with this string transformation ?! Souldn't it be done in # XXX: What with this string transformation ?! Souldn't it be done in
# dtml instead ? ... yes, but how to be bw compatible ? # dtml instead ? ... yes, but how to be bw compatible ?
......
...@@ -1367,11 +1367,11 @@ class ListBoxRenderer: ...@@ -1367,11 +1367,11 @@ class ListBoxRenderer:
return DomainSelection(domain_dict = root_dict).__of__(self.getContext()) return DomainSelection(domain_dict = root_dict).__of__(self.getContext())
@lazyMethod @lazyMethod
def getStatSelectExpression(self): def getStatSelectDict(self):
"""Return a string which expresses the information retrieved by SELECT for """Return a dict which expresses the information retrieved by SELECT for
the statistics. the statistics.
""" """
select_expression_list = [] select_dict = {}
if self.showStat(): if self.showStat():
stats = self.getSelectionTool().getSelectionStats(self.getSelectionName(), REQUEST = self.request) stats = self.getSelectionTool().getSelectionStats(self.getSelectionName(), REQUEST = self.request)
stat_column_list = self.getStatColumnList() stat_column_list = self.getStatColumnList()
...@@ -1386,13 +1386,13 @@ class ListBoxRenderer: ...@@ -1386,13 +1386,13 @@ class ListBoxRenderer:
if (column is not None) and (column[0] == column[1]): if (column is not None) and (column[0] == column[1]):
try: try:
if stats[index] != ' ': if stats[index] != ' ':
select_expression_list.append('%s(%s) AS %s' % (stats[index], sql, alias)) select_dict[alias] = '%s(%s)' % (stats[index], sql)
else: else:
select_expression_list.append("'' AS %s" % alias) select_dict[alias] = "''"
except IndexError: except IndexError:
select_expression_list.append("'' AS %s" % alias) select_dict[alias] = "''"
return ', '.join(select_expression_list) return select_dict
def makeReportTreeList(self, root_dict = None, report_path = None, base_category = None, depth = 0, def makeReportTreeList(self, root_dict = None, report_path = None, base_category = None, depth = 0,
unfolded_list = (), is_report_opened = True, sort_on = (('id', 'ASC'),), unfolded_list = (), is_report_opened = True, sort_on = (('id', 'ASC'),),
...@@ -1618,7 +1618,7 @@ class ListBoxRenderer: ...@@ -1618,7 +1618,7 @@ class ListBoxRenderer:
# First, get the statitics by the global stat method. # First, get the statitics by the global stat method.
param_dict = self.getParamDict() param_dict = self.getParamDict()
new_param_dict = param_dict.copy() new_param_dict = param_dict.copy()
new_param_dict['select_expression'] = self.getStatSelectExpression() new_param_dict['select_dict'] = self.getStatSelectDict()
selection = self.getSelection() selection = self.getSelection()
selection.edit(params = new_param_dict) selection.edit(params = new_param_dict)
...@@ -1702,7 +1702,7 @@ class ListBoxRenderer: ...@@ -1702,7 +1702,7 @@ class ListBoxRenderer:
selection = self.getSelection() selection = self.getSelection()
selection_tool = self.getSelectionTool() selection_tool = self.getSelectionTool()
report_list = selection.getReportList() report_list = selection.getReportList()
stat_select_expression = self.getStatSelectExpression() stat_select_dict = self.getStatSelectDict()
stat_method = self.getStatMethod() stat_method = self.getStatMethod()
count_method = self.getCountMethod() count_method = self.getCountMethod()
list_method = self.getListMethod() list_method = self.getListMethod()
...@@ -1768,9 +1768,9 @@ class ListBoxRenderer: ...@@ -1768,9 +1768,9 @@ class ListBoxRenderer:
stat_method) stat_method)
if report_tree.is_pure_summary and self.showStat(): if report_tree.is_pure_summary and self.showStat():
# Push a new select_expression. # Push a new select_dict.
new_param_dict = param_dict.copy() new_param_dict = param_dict.copy()
new_param_dict['select_expression'] = stat_select_expression new_param_dict['select_dict'] = stat_select_dict
selection.edit(params = new_param_dict) selection.edit(params = new_param_dict)
# Query the stat. # Query the stat.
......
...@@ -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,
'group_by': group_by,
'query': query, 'query': query,
'limit': None} '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)
......
...@@ -216,7 +216,7 @@ class EGOVUserManager(ERP5UserManager): ...@@ -216,7 +216,7 @@ class EGOVUserManager(ERP5UserManager):
newSecurityManager(self, self.getUser(SUPER_USER)) newSecurityManager(self, self.getUser(SUPER_USER))
try: try:
result = portal.portal_catalog.unrestrictedSearchResults( result = portal.portal_catalog.unrestrictedSearchResults(
select_expression='reference', select_list=['reference'],
portal_type=self.portal_type_list, reference=login) portal_type=self.portal_type_list, reference=login)
if len(result) != 1: # we won't proceed with groups if len(result) != 1: # we won't proceed with groups
if len(result) > 1: # configuration is screwed if len(result) > 1: # configuration is screwed
......
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