Mercurial > piecrust2
diff piecrust/taxonomies.py @ 317:6c5de6edacf7
internal: Be more forgiving about building `Taxonomy` objects. Add `setting_name`.
The setting name of a taxonomy is whatever name is used to assign terms of that
taxonomy to a page. If the taxonomy is "multiple", this is the name of the
taxonomy. If not, it's the term name (a singular name).
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 28 Mar 2015 14:17:50 -0700 |
parents | f130365568ff |
children | e7b865f8f335 |
line wrap: on
line diff
--- a/piecrust/taxonomies.py Sat Mar 28 12:41:02 2015 -0700 +++ b/piecrust/taxonomies.py Sat Mar 28 14:17:50 2015 -0700 @@ -5,11 +5,17 @@ def __init__(self, app, name, config): self.app = app self.name = name - self.term_name = config['term'] - self.is_multiple = config['multiple'] - self.page_ref = config['page'] + self.term_name = config.get('term', name) + self.is_multiple = config.get('multiple', False) + self.page_ref = config.get('page') self._source_page_refs = {} + @property + def setting_name(self): + if self.is_multiple: + return self.name + return self.term_name + def resolvePagePath(self, source_name): pr = self.getPageRef(source_name) try: