Mercurial > piecrust2
diff piecrust/sources/base.py @ 853:f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
The asset pipeline is still the only function pipeline at this point.
* No more `QualifiedPage`, and several other pieces of code deleted.
* Data providers are simpler and more focused. For instance, the page iterator
doesn't try to support other types of items.
* Route parameters are proper known source metadata to remove the confusion
between the two.
* Make the baker and pipeline more correctly manage records and record
histories.
* Add support for record collapsing and deleting stale outputs in the asset
pipeline.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 21 May 2017 00:06:59 -0700 |
parents | 4850f8c21b6e |
children | 08e02c2a2a1a |
line wrap: on
line diff
--- a/piecrust/sources/base.py Wed May 17 00:11:48 2017 -0700 +++ b/piecrust/sources/base.py Sun May 21 00:06:59 2017 -0700 @@ -1,5 +1,6 @@ import logging import collections +from werkzeug.utils import cached_property # Source realms, to differentiate sources in the site itself ('User') @@ -40,6 +41,12 @@ class ContentItem: """ Describes a piece of content. + + Some known metadata that PieCrust will use include: + - `route_params`: A dictionary of route parameters to generate + the URL to the content. + - `config`: A dictionary of configuration settings to merge + into the settings found in the content itself. """ def __init__(self, spec, metadata): self.spec = spec @@ -80,7 +87,11 @@ return self.app.theme_dir return self.app.root_dir - def openItem(self, item, mode='r'): + @cached_property + def route(self): + return self.app.getSourceRoute(self.name) + + def openItem(self, item, mode='r', **kwargs): raise NotImplementedError() def getItemMtime(self, item):