summaryrefslogtreecommitdiffstats
path: root/src/collective/dms/thesaurus/browser/thesaurusview.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/collective/dms/thesaurus/browser/thesaurusview.py')
-rw-r--r--src/collective/dms/thesaurus/browser/thesaurusview.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/collective/dms/thesaurus/browser/thesaurusview.py b/src/collective/dms/thesaurus/browser/thesaurusview.py
index 4bfc144..9f8412d 100644
--- a/src/collective/dms/thesaurus/browser/thesaurusview.py
+++ b/src/collective/dms/thesaurus/browser/thesaurusview.py
@@ -86,18 +86,22 @@ class ListKeywordsView(BrowserView):
_items = None
- def getItems(self):
+ def getItems(self, query=None):
context = self.context
if self._items is not None:
return self._items
titles = list()
self._items = list()
+ kwargs = {}
+ if query:
+ kwargs['SearchableText'] = query
+
catalog = getToolByName(context, 'portal_catalog')
path = '/'.join(context.getPhysicalPath())
for brain in catalog(portal_type='dmskeyword',
- path={'query': path,'depth': 1}
- ) :
+ path={'query': path,'depth': 1},
+ **kwargs):
obj = brain.getObject()
normalized = normalizer.normalize(obj.title).lower()
if normalized in titles:
@@ -129,12 +133,14 @@ class ListKeywordsView(BrowserView):
other = []
q = query_string.lower()
regex = re.compile(r"[\s'()]")
- items = self.getItems()
+ items = self.getItems(query_string)
+ done = {}
for normalized, title, id in items:
for term in query_terms:
if not term in normalized.lower():
break
else:
+ done[id] = True
item = '%s|%s' % (title, id)
if normalized.lower().startswith(q):
startswith.append((normalized, item))
@@ -146,6 +152,12 @@ class ListKeywordsView(BrowserView):
else:
other.append((normalized, item))
+ for normalized, title, id in items:
+ if done.get(id):
+ continue
+ item = '%s|%s' % (title, id)
+ other.append((normalized, item))
+
startswith.sort()
intermediate.sort()
other.sort()