Mercurial > piecrust2
comparison 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 |
comparison
equal
deleted
inserted
replaced
852:4850f8c21b6e | 853:f070a4fc033c |
---|---|
1 import logging | 1 import logging |
2 import collections | 2 import collections |
3 from werkzeug.utils import cached_property | |
3 | 4 |
4 | 5 |
5 # Source realms, to differentiate sources in the site itself ('User') | 6 # Source realms, to differentiate sources in the site itself ('User') |
6 # and sources in the site's theme ('Theme'). | 7 # and sources in the site's theme ('Theme'). |
7 REALM_USER = 0 | 8 REALM_USER = 0 |
38 CONTENT_TYPE_ASSET = 1 | 39 CONTENT_TYPE_ASSET = 1 |
39 | 40 |
40 | 41 |
41 class ContentItem: | 42 class ContentItem: |
42 """ Describes a piece of content. | 43 """ Describes a piece of content. |
44 | |
45 Some known metadata that PieCrust will use include: | |
46 - `route_params`: A dictionary of route parameters to generate | |
47 the URL to the content. | |
48 - `config`: A dictionary of configuration settings to merge | |
49 into the settings found in the content itself. | |
43 """ | 50 """ |
44 def __init__(self, spec, metadata): | 51 def __init__(self, spec, metadata): |
45 self.spec = spec | 52 self.spec = spec |
46 self.metadata = metadata | 53 self.metadata = metadata |
47 | 54 |
78 def root_dir(self): | 85 def root_dir(self): |
79 if self.is_theme_source: | 86 if self.is_theme_source: |
80 return self.app.theme_dir | 87 return self.app.theme_dir |
81 return self.app.root_dir | 88 return self.app.root_dir |
82 | 89 |
83 def openItem(self, item, mode='r'): | 90 @cached_property |
91 def route(self): | |
92 return self.app.getSourceRoute(self.name) | |
93 | |
94 def openItem(self, item, mode='r', **kwargs): | |
84 raise NotImplementedError() | 95 raise NotImplementedError() |
85 | 96 |
86 def getItemMtime(self, item): | 97 def getItemMtime(self, item): |
87 raise NotImplementedError() | 98 raise NotImplementedError() |
88 | 99 |