src/pyams_thesaurus/thesaurus.py
changeset 7 6a22cec2899b
parent 4 5dc0c1fa6af6
child 13 5717572bf2a8
--- a/src/pyams_thesaurus/thesaurus.py	Wed Jun 17 10:01:13 2015 +0200
+++ b/src/pyams_thesaurus/thesaurus.py	Tue Jun 30 14:19:52 2015 +0200
@@ -115,7 +115,6 @@
         self.reset_terms_parent()
         self.reset_top_terms()
 
-    @property
     def sublocations(self):
         return self.terms, self.catalog
 
@@ -128,7 +127,9 @@
         self._top_terms = [term for term in value or () if term.usage is None]
 
     def init_catalog(self):
+        # Init catalog
         catalog = self.catalog = Catalog()
+        locate(catalog, self)
         # Init fulltext search catalog
         catalog['fulltext'] = TextIndexWithInterface(IThesaurusTerm, 'label', language=self.language)
         # Init stemmed search catalog
@@ -202,6 +203,11 @@
         self.top_terms = [term for term in self.terms.values()
                           if (not term.generic) and (not term.usage)]
 
+    def get_top_terms(self, extract=None):
+        if extract is None:
+            return self.top_terms
+        return [term for term in self.top_terms if extract in term.extracts]
+
     def clear(self):
         self.terms.clear()
         self.catalog.reset()