Merge from trunk

This commit is contained in:
Charles Haley 2010-05-25 11:49:01 +01:00
commit 9aebbc58d6

View File

@ -628,23 +628,24 @@ class ResultCache(SearchQueryParser):
def search(self, query, return_matches=False, def search(self, query, return_matches=False,
ignore_search_restriction=False): ignore_search_restriction=False):
if not query or not query.strip():
q = '' q = ''
if not query or not query.strip():
if not ignore_search_restriction: if not ignore_search_restriction:
q = self.search_restriction q = self.search_restriction
elif not ignore_search_restriction: else:
q = query
if not ignore_search_restriction:
q = u'%s (%s)' % (self.search_restriction, query) q = u'%s (%s)' % (self.search_restriction, query)
if not q: if not q:
if return_matches: if return_matches:
return list(self._map) # when return_matches, do not update the maps! return list(self._map) # when return_matches, do not update the maps!
self._map_filtered = list(self._map) self._map_filtered = list(self._map)
return [] return
matches = sorted(self.parse(q)) matches = sorted(self.parse(q))
ans = [id for id in self._map if id in matches] ans = [id for id in self._map if id in matches]
if return_matches: if return_matches:
return ans return ans
self._map_filtered = ans self._map_filtered = ans
return []
def set_search_restriction(self, s): def set_search_restriction(self, s):
self.search_restriction = s self.search_restriction = s