--- a/src/pyams_thesaurus/interfaces/thesaurus.py Wed Jun 17 10:01:13 2015 +0200
+++ b/src/pyams_thesaurus/interfaces/thesaurus.py Tue Jun 30 14:19:52 2015 +0200
@@ -90,6 +90,9 @@
def reset_terms_parent(self):
"""Reset thesaurus terms parent attribute"""
+ def get_top_terms(self, extract=None):
+ """Get top terms, for given extract or for the whole thesaurus"""
+
def reset_top_terms(self):
"""Reset thesaurus top terms"""
--- 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()