Mercurial > piecrust2
annotate piecrust/sources/base.py @ 1188:a7c43131d871
bake: Fix file write flushing problem with Python 3.8+
Writing the cache files fails in Python 3.8 because it looks like flushing
behaviour has changed. We need to explicitly flush. And even then, in very
rare occurrences, it looks like it can still run into racing conditions,
so we do a very hacky and ugly "retry" loop when fetching cached data :(
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 15 Jun 2021 22:36:23 -0700 |
parents | a6618fdab37e |
children |
rev | line source |
---|---|
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 import logging |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
2 import collections |
853
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
3 from werkzeug.utils import cached_property |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
5 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
6 # Source realms, to differentiate sources in the site itself ('User') |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
7 # and sources in the site's theme ('Theme'). |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
8 REALM_USER = 0 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
9 REALM_THEME = 1 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
10 REALM_NAMES = { |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
11 REALM_USER: 'User', |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
12 REALM_THEME: 'Theme'} |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
13 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
14 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
15 # Types of relationships a content source can be asked for. |
977
84fc72a17f7a
sources: Changes in related contents management.
Ludovic Chabant <ludovic@chabant.com>
parents:
932
diff
changeset
|
16 REL_PARENT_GROUP = 1 |
84fc72a17f7a
sources: Changes in related contents management.
Ludovic Chabant <ludovic@chabant.com>
parents:
932
diff
changeset
|
17 REL_LOGICAL_PARENT_ITEM = 2 |
1078
a6618fdab37e
sources: Fix some invalid relationship name.
Ludovic Chabant <ludovic@chabant.com>
parents:
989
diff
changeset
|
18 REL_LOGICAL_CHILD_GROUP = 3 |
854
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
19 REL_ASSETS = 10 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
20 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
21 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 logger = logging.getLogger(__name__) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
24 |
555
daf8df5ade7d
serve: Refactor the server to make pieces usable by the debugging middleware.
Ludovic Chabant <ludovic@chabant.com>
parents:
440
diff
changeset
|
25 class SourceNotFoundError(Exception): |
daf8df5ade7d
serve: Refactor the server to make pieces usable by the debugging middleware.
Ludovic Chabant <ludovic@chabant.com>
parents:
440
diff
changeset
|
26 pass |
daf8df5ade7d
serve: Refactor the server to make pieces usable by the debugging middleware.
Ludovic Chabant <ludovic@chabant.com>
parents:
440
diff
changeset
|
27 |
daf8df5ade7d
serve: Refactor the server to make pieces usable by the debugging middleware.
Ludovic Chabant <ludovic@chabant.com>
parents:
440
diff
changeset
|
28 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
29 class InsufficientRouteParameters(Exception): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
30 pass |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
31 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
32 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
33 class AbortedSourceUseError(Exception): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
34 pass |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
35 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
36 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
37 class GeneratedContentException(Exception): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
38 pass |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
39 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
40 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
41 CONTENT_TYPE_PAGE = 0 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
42 CONTENT_TYPE_ASSET = 1 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
43 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
44 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
45 class ContentItem: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
46 """ Describes a piece of content. |
853
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
47 |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
48 Some known metadata that PieCrust will use include: |
854
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
49 - `date`: A `datetime.date` object that will set the date of the page. |
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
50 - `datetime`: A `datetime.datetime` object that will set the date and |
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
51 time of the page. |
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
52 - `route_params`: A dictionary of route parameters to generate the |
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
53 URL to the content. |
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
54 - `config`: A dictionary of configuration settings to merge into the |
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
55 settings found in the content itself. |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
56 """ |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
57 def __init__(self, spec, metadata): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
58 self.spec = spec |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
59 self.metadata = metadata |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
60 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
61 @property |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
62 def is_group(self): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
63 return False |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
64 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
65 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
66 class ContentGroup: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
67 """ Describes a group of `ContentItem`s. |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
68 """ |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
69 def __init__(self, spec, metadata): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
70 self.spec = spec |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
71 self.metadata = metadata |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
72 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
73 @property |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
74 def is_group(self): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
75 return True |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
76 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
77 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
78 class ContentSource: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
79 """ A source for content. |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
80 """ |
979
45ad976712ec
tests: Big push to get the tests to pass again.
Ludovic Chabant <ludovic@chabant.com>
parents:
977
diff
changeset
|
81 SOURCE_NAME = None |
854
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
82 DEFAULT_PIPELINE_NAME = None |
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
83 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
84 def __init__(self, app, name, config): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
85 self.app = app |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
86 self.name = name |
299
88bffd469b04
sources: Make sure page sources have some basic config info they need.
Ludovic Chabant <ludovic@chabant.com>
parents:
242
diff
changeset
|
87 self.config = config or {} |
871
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
88 self._cache = None |
905
1d0364614665
internal: Sources can cache their pages in addition to their items.
Ludovic Chabant <ludovic@chabant.com>
parents:
871
diff
changeset
|
89 self._page_cache = None |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
90 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
91 @property |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
92 def is_theme_source(self): |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
93 return self.config['realm'] == REALM_THEME |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
94 |
853
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
95 @cached_property |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
96 def route(self): |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
97 return self.app.getSourceRoute(self.name) |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
98 |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
99 def openItem(self, item, mode='r', **kwargs): |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
100 raise NotImplementedError() |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
101 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
102 def getItemMtime(self, item): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
103 raise NotImplementedError() |
114
371a6c879ab9
When possible, try and batch-load pages so we only lock once.
Ludovic Chabant <ludovic@chabant.com>
parents:
84
diff
changeset
|
104 |
905
1d0364614665
internal: Sources can cache their pages in addition to their items.
Ludovic Chabant <ludovic@chabant.com>
parents:
871
diff
changeset
|
105 def getAllPages(self): |
1d0364614665
internal: Sources can cache their pages in addition to their items.
Ludovic Chabant <ludovic@chabant.com>
parents:
871
diff
changeset
|
106 if self._page_cache is not None: |
1d0364614665
internal: Sources can cache their pages in addition to their items.
Ludovic Chabant <ludovic@chabant.com>
parents:
871
diff
changeset
|
107 return self._page_cache |
1d0364614665
internal: Sources can cache their pages in addition to their items.
Ludovic Chabant <ludovic@chabant.com>
parents:
871
diff
changeset
|
108 |
1d0364614665
internal: Sources can cache their pages in addition to their items.
Ludovic Chabant <ludovic@chabant.com>
parents:
871
diff
changeset
|
109 getter = self.app.getPage |
1d0364614665
internal: Sources can cache their pages in addition to their items.
Ludovic Chabant <ludovic@chabant.com>
parents:
871
diff
changeset
|
110 self._page_cache = [getter(self, i) for i in self.getAllContents()] |
1d0364614665
internal: Sources can cache their pages in addition to their items.
Ludovic Chabant <ludovic@chabant.com>
parents:
871
diff
changeset
|
111 return self._page_cache |
1d0364614665
internal: Sources can cache their pages in addition to their items.
Ludovic Chabant <ludovic@chabant.com>
parents:
871
diff
changeset
|
112 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
113 def getAllContents(self): |
871
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
114 if self._cache is not None: |
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
115 return self._cache |
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
116 |
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
117 cache = [] |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
118 stack = collections.deque() |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
119 stack.append(None) |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
120 while len(stack) > 0: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
121 cur = stack.popleft() |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
122 try: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
123 contents = self.getContents(cur) |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
124 except GeneratedContentException: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
125 continue |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
126 if contents is not None: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
127 for c in contents: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
128 if c.is_group: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
129 stack.append(c) |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
130 else: |
871
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
131 cache.append(c) |
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
132 self._cache = cache |
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
133 return cache |
318
ac9b94c8fb37
internal: Add utility function to get a page from a source.
Ludovic Chabant <ludovic@chabant.com>
parents:
299
diff
changeset
|
134 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
135 def getContents(self, group): |
932
0eca08213354
sources: Give better exception messages when a class is missing a method.
Ludovic Chabant <ludovic@chabant.com>
parents:
905
diff
changeset
|
136 raise NotImplementedError( |
0eca08213354
sources: Give better exception messages when a class is missing a method.
Ludovic Chabant <ludovic@chabant.com>
parents:
905
diff
changeset
|
137 "'%s' doesn't implement 'getContents'." % self.__class__) |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
138 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
139 def getRelatedContents(self, item, relationship): |
932
0eca08213354
sources: Give better exception messages when a class is missing a method.
Ludovic Chabant <ludovic@chabant.com>
parents:
905
diff
changeset
|
140 raise NotImplementedError( |
0eca08213354
sources: Give better exception messages when a class is missing a method.
Ludovic Chabant <ludovic@chabant.com>
parents:
905
diff
changeset
|
141 "'%s' doesn't implement 'getRelatedContents'." % self.__class__) |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
142 |
989
8adc27285d93
bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
986
diff
changeset
|
143 def findContentFromSpec(self, spec): |
932
0eca08213354
sources: Give better exception messages when a class is missing a method.
Ludovic Chabant <ludovic@chabant.com>
parents:
905
diff
changeset
|
144 raise NotImplementedError( |
989
8adc27285d93
bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
986
diff
changeset
|
145 "'%s' doesn't implement 'findContentFromSpec'." % self.__class__) |
866
d9059257743c
refactor: Make the linker work again.
Ludovic Chabant <ludovic@chabant.com>
parents:
862
diff
changeset
|
146 |
989
8adc27285d93
bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
986
diff
changeset
|
147 def findContentFromRoute(self, route_params): |
932
0eca08213354
sources: Give better exception messages when a class is missing a method.
Ludovic Chabant <ludovic@chabant.com>
parents:
905
diff
changeset
|
148 raise NotImplementedError( |
989
8adc27285d93
bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
986
diff
changeset
|
149 "'%s' doesn't implement 'findContentFromRoute'." % self.__class__) |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
150 |
792
58ebf50235a5
routing: Simplify how routes are defined.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
151 def getSupportedRouteParameters(self): |
932
0eca08213354
sources: Give better exception messages when a class is missing a method.
Ludovic Chabant <ludovic@chabant.com>
parents:
905
diff
changeset
|
152 raise NotImplementedError( |
0eca08213354
sources: Give better exception messages when a class is missing a method.
Ludovic Chabant <ludovic@chabant.com>
parents:
905
diff
changeset
|
153 "'%s' doesn't implement 'getSupportedRouteParameters'." % |
0eca08213354
sources: Give better exception messages when a class is missing a method.
Ludovic Chabant <ludovic@chabant.com>
parents:
905
diff
changeset
|
154 self.__class__) |
792
58ebf50235a5
routing: Simplify how routes are defined.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
155 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
156 def prepareRenderContext(self, ctx): |
824
e01473c3ea7e
Allow page source to post-process page config at the end of page loading
Ben Artin <ben@artins.org>
parents:
792
diff
changeset
|
157 pass |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
158 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
159 def onRouteFunctionUsed(self, route_params): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
160 pass |
826
7f235e65ef5d
Allow PageSource to provide a custom assetor
Ben Artin <ben@artins.org>
parents:
792
diff
changeset
|
161 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
162 def describe(self): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
163 return None |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
164 |