Mercurial > piecrust2
view piecrust/taxonomies.py @ 371:c2ca72fb7f0b 2.0.0a8
caching: Use separate caches for config variants and other contexts.
* The `_cache` directory is now organized in multiple "sub-caches" for
different contexts.
* A new context is created when config variants or overrides are applied.
* `serve` context uses a different context that the other commends, to prevent
the `bake` command's output from messing up the preview server (e.g. with
how asset URLs are generated differently between the two).
* Fix a few places where the cache directory was referenced directly.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 03 May 2015 23:59:46 -0700 |
parents | 6c5de6edacf7 |
children | e7b865f8f335 |
line wrap: on
line source
from piecrust.sources.pageref import PageRef, PageNotFoundError class Taxonomy(object): def __init__(self, app, name, config): self.app = app self.name = name 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: return pr.path except PageNotFoundError: return None def getPageRef(self, source_name): if source_name in self._source_page_refs: return self._source_page_refs[source_name] source = self.app.getSource(source_name) ref_path = (source.getTaxonomyPageRef(self.name) or '%s:%s' % (source_name, self.page_ref)) page_ref = PageRef(self.app, ref_path) self._source_page_refs[source_name] = page_ref return page_ref