Commit c208c12d authored by Vincent Pelletier's avatar Vincent Pelletier

all: Stop using *_expression catalog arguments.

These are the easy uses, there are more to come.
parent aaa0e481
...@@ -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
......
...@@ -292,7 +292,10 @@ class OscommerceERP5NodeConduit(TioSafeBaseConduit): ...@@ -292,7 +292,10 @@ 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={
'query': 'default_address',
'operator': '!=',
},
) )
try: try:
address = address_list[address_index].getObject() address = address_list[address_index].getObject()
...@@ -385,7 +388,10 @@ class OscommerceERP5NodeConduit(TioSafeBaseConduit): ...@@ -385,7 +388,10 @@ 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={
'query': 'default_address',
'operator': '!=',
},
) )
address_id = address_list[address_index].getId() address_id = address_list[address_index].getId()
try: try:
......
...@@ -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)
......
...@@ -584,8 +584,8 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -584,8 +584,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 ?
......
...@@ -3674,7 +3674,7 @@ VALUES ...@@ -3674,7 +3674,7 @@ VALUES
def test_IndexationContextIndependence(self): def test_IndexationContextIndependence(self):
def doCatalog(catalog, document): def doCatalog(catalog, document):
catalog.catalogObjectList([document], check_uid=0) catalog.catalogObjectList([document], check_uid=0)
result = catalog(select_expression='reference', uid=document.getUid()) result = catalog(select_list=['reference'], uid=document.getUid())
self.assertEqual(len(result), 1) self.assertEqual(len(result), 1)
return result[0].reference return result[0].reference
...@@ -3720,8 +3720,10 @@ VALUES ...@@ -3720,8 +3720,10 @@ VALUES
self.tic() self.tic()
portal_catalog = self.getCatalogTool() portal_catalog = self.getCatalogTool()
res = portal_catalog.searchResults( res = portal_catalog.searchResults(
select_expression='count(DISTINCT catalog.reference) AS count_reference', select_dict={
group_by_expression='catalog.reference', 'count_reference': 'count(DISTINCT reference)',
},
group_by=['reference'],
portal_type='Person', portal_type='Person',
) )
self.assertEqual(1, len(res)) self.assertEqual(1, len(res))
......
...@@ -347,7 +347,10 @@ class ERP5NodeConduit(TioSafeBaseConduit): ...@@ -347,7 +347,10 @@ class ERP5NodeConduit(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={
'query': 'default_address',
'operator': '!=',
},
) )
try: try:
address = address_list[address_index].getObject() address = address_list[address_index].getObject()
...@@ -444,7 +447,10 @@ class ERP5NodeConduit(TioSafeBaseConduit): ...@@ -444,7 +447,10 @@ class ERP5NodeConduit(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={
'query': 'default_address',
'operator': '!=',
},
) )
address_id = address_list[address_index].getId() address_id = address_list[address_index].getId()
try: try:
......
...@@ -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