Mercurial > piecrust2
view piecrust/sources/array.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 | f130365568ff |
children | e7b865f8f335 |
line wrap: on
line source
from piecrust.sources.base import PageSource from piecrust.sources.mixins import SimplePaginationSourceMixin class CachedPageFactory(object): """ A `PageFactory` (in appearance) that already has a page built. """ def __init__(self, page): self._page = page @property def rel_path(self): return self._page.rel_path @property def metadata(self): return self._page.source_metadata @property def ref_spec(self): return self._page.ref_spec @property def path(self): return self._page.path def buildPage(self): return self._page class ArraySource(PageSource, SimplePaginationSourceMixin): def __init__(self, app, inner_source, name='array', config=None): super(ArraySource, self).__init__(app, name, config or {}) self.inner_source = inner_source @property def page_count(self): return len(self.inner_source) def getPageFactories(self): for p in self.inner_source: yield CachedPageFactory(p)