Mercurial > piecrust2
annotate piecrust/sources/base.py @ 905:1d0364614665
internal: Sources can cache their pages in addition to their items.
Added `getAllPages` to content sources to prevent having to look up cached
page objects in the page repository all the time.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 23 Jul 2017 08:26:57 -0700 |
parents | 504ddb370df8 |
children | 0eca08213354 |
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. |
862
fddaf43424e2
refactor: Get the page assets to work again in the server.
Ludovic Chabant <ludovic@chabant.com>
parents:
855
diff
changeset
|
16 REL_LOGICAL_PARENT_ITEM = 1 |
fddaf43424e2
refactor: Get the page assets to work again in the server.
Ludovic Chabant <ludovic@chabant.com>
parents:
855
diff
changeset
|
17 REL_LOGICAl_CHILD_GROUP = 2 |
854
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
18 REL_ASSETS = 10 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
19 |
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 logger = logging.getLogger(__name__) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 |
555
daf8df5ade7d
serve: Refactor the server to make pieces usable by the debugging middleware.
Ludovic Chabant <ludovic@chabant.com>
parents:
440
diff
changeset
|
24 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
|
25 pass |
daf8df5ade7d
serve: Refactor the server to make pieces usable by the debugging middleware.
Ludovic Chabant <ludovic@chabant.com>
parents:
440
diff
changeset
|
26 |
daf8df5ade7d
serve: Refactor the server to make pieces usable by the debugging middleware.
Ludovic Chabant <ludovic@chabant.com>
parents:
440
diff
changeset
|
27 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
28 class InsufficientRouteParameters(Exception): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
29 pass |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
30 |
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 class AbortedSourceUseError(Exception): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
33 pass |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
34 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
35 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
36 class GeneratedContentException(Exception): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
37 pass |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
38 |
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 CONTENT_TYPE_PAGE = 0 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
41 CONTENT_TYPE_ASSET = 1 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
42 |
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 class ContentItem: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
45 """ Describes a piece of content. |
853
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
46 |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
47 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
|
48 - `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
|
49 - `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
|
50 time of the page. |
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
51 - `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
|
52 URL to the content. |
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
53 - `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
|
54 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
|
55 """ |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
56 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
|
57 self.spec = spec |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
58 self.metadata = metadata |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
59 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
60 @property |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
61 def is_group(self): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
62 return False |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
63 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
64 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
65 class ContentGroup: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
66 """ 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
|
67 """ |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
68 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
|
69 self.spec = spec |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
70 self.metadata = metadata |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
71 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
72 @property |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
73 def is_group(self): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
74 return True |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
75 |
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 class ContentSource: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
78 """ A source for content. |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
79 """ |
854
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
80 DEFAULT_PIPELINE_NAME = None |
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
81 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
82 def __init__(self, app, name, config): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
83 self.app = app |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
84 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
|
85 self.config = config or {} |
871
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
86 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
|
87 self._page_cache = None |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
88 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
89 @property |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
90 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
|
91 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
|
92 |
853
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
93 @cached_property |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
94 def route(self): |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
95 return self.app.getSourceRoute(self.name) |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
96 |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
97 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
|
98 raise NotImplementedError() |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
99 |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
100 def getItemMtime(self, item): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
101 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
|
102 |
905
1d0364614665
internal: Sources can cache their pages in addition to their items.
Ludovic Chabant <ludovic@chabant.com>
parents:
871
diff
changeset
|
103 def getAllPages(self): |
1d0364614665
internal: Sources can cache their pages in addition to their items.
Ludovic Chabant <ludovic@chabant.com>
parents:
871
diff
changeset
|
104 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
|
105 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
|
106 |
1d0364614665
internal: Sources can cache their pages in addition to their items.
Ludovic Chabant <ludovic@chabant.com>
parents:
871
diff
changeset
|
107 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
|
108 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
|
109 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
|
110 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
111 def getAllContents(self): |
871
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
112 if self._cache is not None: |
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
113 return self._cache |
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
114 |
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
115 cache = [] |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
116 stack = collections.deque() |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
117 stack.append(None) |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
118 while len(stack) > 0: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
119 cur = stack.popleft() |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
120 try: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
121 contents = self.getContents(cur) |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
122 except GeneratedContentException: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
123 continue |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
124 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
|
125 for c in contents: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
126 if c.is_group: |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
127 stack.append(c) |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
128 else: |
871
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
129 cache.append(c) |
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
130 self._cache = cache |
504ddb370df8
refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents:
866
diff
changeset
|
131 return cache |
318
ac9b94c8fb37
internal: Add utility function to get a page from a source.
Ludovic Chabant <ludovic@chabant.com>
parents:
299
diff
changeset
|
132 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
133 def getContents(self, group): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
134 raise NotImplementedError("'%s' doesn't implement 'getContents'." % |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
135 self.__class__) |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
136 |
862
fddaf43424e2
refactor: Get the page assets to work again in the server.
Ludovic Chabant <ludovic@chabant.com>
parents:
855
diff
changeset
|
137 def getParentGroup(self, item): |
fddaf43424e2
refactor: Get the page assets to work again in the server.
Ludovic Chabant <ludovic@chabant.com>
parents:
855
diff
changeset
|
138 raise NotImplementedError() |
fddaf43424e2
refactor: Get the page assets to work again in the server.
Ludovic Chabant <ludovic@chabant.com>
parents:
855
diff
changeset
|
139 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
140 def getRelatedContents(self, item, relationship): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
141 raise NotImplementedError() |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
142 |
866
d9059257743c
refactor: Make the linker work again.
Ludovic Chabant <ludovic@chabant.com>
parents:
862
diff
changeset
|
143 def findGroup(self, rel_spec): |
d9059257743c
refactor: Make the linker work again.
Ludovic Chabant <ludovic@chabant.com>
parents:
862
diff
changeset
|
144 raise NotImplementedError() |
d9059257743c
refactor: Make the linker work again.
Ludovic Chabant <ludovic@chabant.com>
parents:
862
diff
changeset
|
145 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
146 def findContent(self, route_params): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
147 raise NotImplementedError() |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
148 |
792
58ebf50235a5
routing: Simplify how routes are defined.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
149 def getSupportedRouteParameters(self): |
58ebf50235a5
routing: Simplify how routes are defined.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
150 raise NotImplementedError() |
58ebf50235a5
routing: Simplify how routes are defined.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
151 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
152 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
|
153 pass |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
154 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
155 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
|
156 pass |
826
7f235e65ef5d
Allow PageSource to provide a custom assetor
Ben Artin <ben@artins.org>
parents:
792
diff
changeset
|
157 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
158 def describe(self): |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
159 return None |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
840
diff
changeset
|
160 |