summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2014-03-31 09:08:05 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2014-03-31 09:08:05 (GMT)
commit101c84d80192b1a2438d6464f8ce15b60967e19a (patch)
tree36638a0b798e7e7e0d84804d1b3af5c0c8e7140d
parent85f0820005c8d8df2be9a2461de438fd0250e950 (diff)
downloadcollective.dms.thesaurus-101c84d80192b1a2438d6464f8ce15b60967e19a.zip
collective.dms.thesaurus-101c84d80192b1a2438d6464f8ce15b60967e19a.tar.gz
collective.dms.thesaurus-101c84d80192b1a2438d6464f8ce15b60967e19a.tar.bz2
helper function to build the recursive list of broader keywords (#4570)
-rw-r--r--src/collective/dms/thesaurus/dmskeyword.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/collective/dms/thesaurus/dmskeyword.py b/src/collective/dms/thesaurus/dmskeyword.py
index 6b72217..d67fa39 100644
--- a/src/collective/dms/thesaurus/dmskeyword.py
+++ b/src/collective/dms/thesaurus/dmskeyword.py
@@ -76,6 +76,16 @@ class DmsKeyword(Item):
words.append(keyword.get_words_for_indexation(limit=limit-1))
return ' '.join(words)
+ def get_keyword_tree(self, limit=5):
+ thesaurus = aq_parent(self)
+ l = [self.id]
+ for broader_keyword in self.broader or []:
+ try:
+ keyword = thesaurus[broader_keyword]
+ except KeyError:
+ continue
+ l.extend(keyword.get_keyword_tree(limit=limit-1))
+ return l
class DmsKeywordSchemaPolicy(DexteritySchemaPolicy):