Predicate: fix empty_criterion_valid check implementation.
It should be only for the case where no predicate criterion exists at all.
... | @@ -222,8 +222,7 @@ class Predicate(XMLObject): | ... | @@ -222,8 +222,7 @@ class Predicate(XMLObject): |
catalog_kw = {} | catalog_kw = {} | ||
catalog_kw.update(kw) # query_table, REQUEST, ignore_empty_string, **kw | catalog_kw.update(kw) # query_table, REQUEST, ignore_empty_string, **kw | ||
criterion_list = self.getCriterionList() | criterion_list = self.getCriterionList() | ||
# BBB: accessor is not present on old Predicate property sheet. | if criterion_list: | ||
if criterion_list or getattr(self, 'isEmptyCriterionValid', lambda: True)(): | |||
for criterion in criterion_list: | for criterion in criterion_list: | ||
p = criterion.property | p = criterion.property | ||
if criterion.min: | if criterion.min: | ||
... | @@ -248,10 +247,6 @@ class Predicate(XMLObject): | ... | @@ -248,10 +247,6 @@ class Predicate(XMLObject): |
else: | else: | ||
f = (i,) if i in f else () | f = (i,) if i in f else () | ||
catalog_kw[p] = list(f) | catalog_kw[p] = list(f) | ||
else: | |||
# By catalog definition, no object has uid 0, so this condition forces an | |||
# empty result. | |||
catalog_kw['uid'] = 0 | |||
portal_catalog = getToolByName(self, 'portal_catalog') | portal_catalog = getToolByName(self, 'portal_catalog') | ||
... | @@ -302,6 +297,13 @@ class Predicate(XMLObject): | ... | @@ -302,6 +297,13 @@ class Predicate(XMLObject): |
if and_expression: | if and_expression: | ||
multimembership_select_list.append(and_expression) | multimembership_select_list.append(and_expression) | ||
# BBB: accessor is not present on old Predicate property sheet. | |||
if not getattr(self, 'isEmptyCriterionValid', lambda: True)() and \ | |||
not catalog_kw and not membership_select_list and not multimembership_select_list: | |||
|
|||
# By catalog definition, no object has uid 0, so this condition forces an | |||
# empty result. | |||
catalog_kw['uid'] = 0 | |||
# Build the join where expression | # Build the join where expression | ||
join_select_list = [] | join_select_list = [] | ||
for k in from_table_dict.iterkeys(): | for k in from_table_dict.iterkeys(): | ||
... | ... |