Commit 7e9642a6 authored by Vincent Pelletier's avatar Vincent Pelletier

Export convenience methods to easily use queryResults.

Also, word-wrap and remove "captain obvious"-style comment.
parent 98748a0e
...@@ -2437,22 +2437,36 @@ class Catalog(Folder, ...@@ -2437,22 +2437,36 @@ class Catalog(Folder,
sql_kw = self._queryResults(REQUEST=REQUEST, build_sql_query_method=build_sql_query_method, **kw) sql_kw = self._queryResults(REQUEST=REQUEST, build_sql_query_method=build_sql_query_method, **kw)
return sql_method(src__=src__, **sql_kw) return sql_method(src__=src__, **sql_kw)
def getSearchResultsMethod(self):
return getattr(self, self.sql_search_results)
def searchResults(self, REQUEST=None, **kw): def searchResults(self, REQUEST=None, **kw):
""" Returns a list of brains from a set of constraints on variables """ """ Returns a list of brains from a set of constraints on variables """
if 'only_group_columns' in kw: if 'only_group_columns' in kw:
# searchResults must be consistent in API with countResults # searchResults must be consistent in API with countResults
raise ValueError('only_group_columns does not belong to this API ' raise ValueError('only_group_columns does not belong to this API '
'level, use queryResults directly') 'level, use queryResults directly')
method = getattr(self, self.sql_search_results) return self.queryResults(
return self.queryResults(method, REQUEST=REQUEST, extra_column_list=self.getCatalogSearchResultKeys(), **kw) self.getSearchResultsMethod(),
REQUEST=REQUEST,
extra_column_list=self.getCatalogSearchResultKeys(),
**kw
)
__call__ = searchResults __call__ = searchResults
def getCountResultsMethod(self):
return getattr(self, self.sql_count_results)
def countResults(self, REQUEST=None, **kw): def countResults(self, REQUEST=None, **kw):
""" Returns the number of items which satisfy the where_expression """ """ Returns the number of items which satisfy the where_expression """
# Get the search method return self.queryResults(
method = getattr(self, self.sql_count_results) self.getCountResultsMethod(),
return self.queryResults(method, REQUEST=REQUEST, extra_column_list=self.getCatalogSearchResultKeys(), only_group_columns=True, **kw) REQUEST=REQUEST,
extra_column_list=self.getCatalogSearchResultKeys(),
only_group_columns=True,
**kw
)
def isAdvancedSearchText(self, search_text): def isAdvancedSearchText(self, search_text):
return isAdvancedSearchText(search_text, self.isValidColumn) return isAdvancedSearchText(search_text, self.isValidColumn)
......
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