Commit 45185ca6 authored by Vincent Pelletier's avatar Vincent Pelletier

Simplify EntireQuery contructor api.

Update caller.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25901 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1fb83497
......@@ -35,6 +35,12 @@ from Products.ZSQLCatalog.Interface.IEntireQuery import IEntireQuery
from Interface.Verify import verifyClass
from Products.ZSQLCatalog.SQLCatalog import profiler_decorator
def defaultDict(value):
if value is None:
return {}
assert isinstance(value, dict)
return value
class EntireQuery(object):
"""
This is not a Query subclass, since it does not define a
......@@ -47,28 +53,18 @@ class EntireQuery(object):
column_map = None
@profiler_decorator
def __init__(self, query, order_by_list=None, group_by_list=None,
def __init__(self, query, order_by_list=(), group_by_list=(),
select_dict=None, limit=None, catalog_table_name=None,
extra_column_list=None, from_expression=None,
extra_column_list=(), from_expression=None,
order_by_override_list=None):
def default(value):
if value is None:
return []
assert isinstance(value, (tuple, list))
return value
def defaultDict(value):
if value is None:
return {}
assert isinstance(value, dict)
return value
self.query = query
self.order_by_list = default(order_by_list)
self.order_by_override_set = frozenset(default(order_by_override_list))
self.group_by_list = default(group_by_list)
self.order_by_list = list(order_by_list)
self.order_by_override_set = frozenset(order_by_override_list)
self.group_by_list = list(group_by_list)
self.select_dict = defaultDict(select_dict)
self.limit = limit
self.catalog_table_name = catalog_table_name
self.extra_column_list = default(extra_column_list)
self.extra_column_list = list(extra_column_list)
self.from_expression = from_expression
def asSearchTextExpression(self, sql_catalog):
......
......@@ -2094,9 +2094,9 @@ class Catalog(Folder,
@profiler_decorator
def buildSQLQuery(self, query_table='catalog', REQUEST=None,
ignore_empty_string=1, only_group_columns=False,
limit=None, extra_column_list=None,
limit=None, extra_column_list=(),
**kw):
group_by_list = kw.pop('group_by_list', kw.pop('group_by', kw.pop('group_by_expression', None)))
group_by_list = kw.pop('group_by_list', kw.pop('group_by', kw.pop('group_by_expression', ())))
if isinstance(group_by_list, basestring):
group_by_list = [x.strip() for x in group_by_list.split(',')]
select_dict = kw.pop('select_dict', kw.pop('select_list', kw.pop('select_expression', None)))
......@@ -2144,7 +2144,7 @@ class Catalog(Folder,
# It is required to support select_expression_key parameter for backward
# compatiblity, but I'm not sure if there can be a serious use for it in
# new API.
order_by_override_list = kw.pop('select_expression_key', None)
order_by_override_list = kw.pop('select_expression_key', ())
query = EntireQuery(
query=self.buildQuery(kw, ignore_empty_string=ignore_empty_string),
order_by_list=order_by_list,
......
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