Mercurial > piecrust2
annotate piecrust/app.py @ 989:8adc27285d93
bake: Big pass on bake performance.
- Reduce the amount of data passed between processes.
- Make inter-process data simple objects to make it easier to test with
alternatives to pickle.
- Make sources have the basic requirement to be able to find a content item
from an item spec (path).
- Make Hoedown the default Markdown formatter.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 19 Nov 2017 14:29:17 -0800 |
parents | eed19a80c00e |
children | 2e5c5d33d62c |
rev | line source |
---|---|
411
e7b865f8f335
bake: Enable multiprocess baking.
Ludovic Chabant <ludovic@chabant.com>
parents:
371
diff
changeset
|
1 import time |
0 | 2 import os.path |
3 import logging | |
758
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
4 import urllib.parse |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
5 from werkzeug.utils import cached_property |
271
12657039c436
internal: Re-use the cached resource directory.
Ludovic Chabant <ludovic@chabant.com>
parents:
260
diff
changeset
|
6 from piecrust import ( |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
7 RESOURCES_DIR, |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
8 CACHE_DIR, TEMPLATES_DIR, ASSETS_DIR, |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
9 THEME_DIR, PLUGINS_DIR, |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
10 CONFIG_PATH, THEME_CONFIG_PATH) |
584
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
11 from piecrust.appconfig import PieCrustConfiguration |
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
12 from piecrust.cache import ExtensibleCache, NullExtensibleCache |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
13 from piecrust.configuration import ConfigurationError |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
14 from piecrust.environment import StandardEnvironment |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
15 from piecrust.page import Page |
758
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
16 from piecrust.plugins.base import PluginLoader |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
17 from piecrust.routing import Route |
0 | 18 |
19 | |
20 logger = logging.getLogger(__name__) | |
21 | |
22 | |
23 class PieCrust(object): | |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
24 def __init__(self, root_dir, cache=True, debug=False, theme_site=False, |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
25 env=None, cache_key=None): |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
26 self.root_dir = root_dir |
0 | 27 self.debug = debug |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
28 self.theme_site = theme_site |
0 | 29 self.plugin_loader = PluginLoader(self) |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
30 self.cache_key = cache_key or 'default' |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
31 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
32 if cache: |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
33 self.cache = ExtensibleCache(self.cache_dir) |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
34 else: |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
35 self.cache = NullExtensibleCache() |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
36 |
853
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
37 if env is None: |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
38 env = StandardEnvironment() |
0 | 39 self.env = env |
853
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
40 env.initialize(self) |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
41 |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
42 stats = env.stats |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
43 stats.registerTimer('SiteConfigLoad') |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
44 stats.registerTimer('PageLoad') |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
45 stats.registerTimer("BuildRenderData") |
904
cc2647360036
internal: Remove unnecessary timer, add timer for lazy data building.
Ludovic Chabant <ludovic@chabant.com>
parents:
885
diff
changeset
|
46 stats.registerTimer("BuildLazyPageData") |
853
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
47 stats.registerTimer("PageRender") |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
48 stats.registerTimer("PageRenderSegments") |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
49 stats.registerTimer("PageRenderLayout") |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
50 stats.registerTimer("PageSerialize") |
989
8adc27285d93
bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
909
diff
changeset
|
51 stats.registerTimer("MergedMapping_get") |
876
d1095774bfcf
refactor: Fix some issues with record/cache entry collisions, add counters.
Ludovic Chabant <ludovic@chabant.com>
parents:
854
diff
changeset
|
52 stats.registerCounter('PageLoads') |
d1095774bfcf
refactor: Fix some issues with record/cache entry collisions, add counters.
Ludovic Chabant <ludovic@chabant.com>
parents:
854
diff
changeset
|
53 stats.registerCounter('PageRenderSegments') |
d1095774bfcf
refactor: Fix some issues with record/cache entry collisions, add counters.
Ludovic Chabant <ludovic@chabant.com>
parents:
854
diff
changeset
|
54 stats.registerCounter('PageRenderLayout') |
411
e7b865f8f335
bake: Enable multiprocess baking.
Ludovic Chabant <ludovic@chabant.com>
parents:
371
diff
changeset
|
55 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
56 @cached_property |
0 | 57 def config(self): |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
58 logger.debug("Creating site configuration...") |
411
e7b865f8f335
bake: Enable multiprocess baking.
Ludovic Chabant <ludovic@chabant.com>
parents:
371
diff
changeset
|
59 start_time = time.perf_counter() |
e7b865f8f335
bake: Enable multiprocess baking.
Ludovic Chabant <ludovic@chabant.com>
parents:
371
diff
changeset
|
60 |
663
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
586
diff
changeset
|
61 if not self.theme_site: |
681
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
62 path = os.path.join(self.root_dir, CONFIG_PATH) |
663
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
586
diff
changeset
|
63 else: |
681
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
64 path = os.path.join(self.root_dir, THEME_CONFIG_PATH) |
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
65 |
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
66 theme_path = None |
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
67 if not self.theme_site and self.theme_dir: |
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
68 theme_path = os.path.join(self.theme_dir, THEME_CONFIG_PATH) |
0 | 69 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
70 config_cache = self.cache.getCache('app') |
675
3df808b133f8
internal: Improve how theme configuration is validated and merged.
Ludovic Chabant <ludovic@chabant.com>
parents:
666
diff
changeset
|
71 config = PieCrustConfiguration( |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
72 path=path, theme_path=theme_path, |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
73 cache=config_cache, theme_config=self.theme_site) |
681
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
74 |
805
fd694f1297c7
config: Cleanup config loading code. Add support for a `local.yml` config.
Ludovic Chabant <ludovic@chabant.com>
parents:
758
diff
changeset
|
75 local_path = os.path.join( |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
76 self.root_dir, 'configs', 'local.yml') |
805
fd694f1297c7
config: Cleanup config loading code. Add support for a `local.yml` config.
Ludovic Chabant <ludovic@chabant.com>
parents:
758
diff
changeset
|
77 config.addVariant(local_path, raise_if_not_found=False) |
fd694f1297c7
config: Cleanup config loading code. Add support for a `local.yml` config.
Ludovic Chabant <ludovic@chabant.com>
parents:
758
diff
changeset
|
78 |
681
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
79 if self.theme_site: |
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
80 variant_path = os.path.join( |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
81 self.root_dir, 'configs', 'theme_preview.yml') |
681
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
82 config.addVariant(variant_path, raise_if_not_found=False) |
0 | 83 |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
84 self.env.stats.stepTimer('SiteConfigLoad', |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
85 time.perf_counter() - start_time) |
0 | 86 return config |
87 | |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
88 @cached_property |
36
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
89 def assets_dirs(self): |
584
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
90 assets_dirs = self._get_configurable_dirs( |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
91 ASSETS_DIR, 'site/assets_dirs') |
36
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
92 |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
93 # Also add the theme directory, if any. |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
94 if self.theme_dir: |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
95 default_theme_dir = os.path.join(self.theme_dir, ASSETS_DIR) |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
96 if os.path.isdir(default_theme_dir): |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
97 assets_dirs.append(default_theme_dir) |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
98 |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
99 return assets_dirs |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
100 |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
101 @cached_property |
0 | 102 def templates_dirs(self): |
584
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
103 templates_dirs = self._get_configurable_dirs( |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
104 TEMPLATES_DIR, 'site/templates_dirs') |
0 | 105 |
36
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
106 # Also, add the theme directory, if any. |
0 | 107 if self.theme_dir: |
108 default_theme_dir = os.path.join(self.theme_dir, TEMPLATES_DIR) | |
109 if os.path.isdir(default_theme_dir): | |
110 templates_dirs.append(default_theme_dir) | |
111 | |
112 return templates_dirs | |
113 | |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
114 @cached_property |
0 | 115 def theme_dir(self): |
709
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
116 # No theme if the curent site is already a theme. |
663
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
586
diff
changeset
|
117 if self.theme_site: |
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
586
diff
changeset
|
118 return None |
709
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
119 |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
120 # See if there's a theme we absolutely want. |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
121 td = self._get_dir(THEME_DIR) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
122 if td is not None: |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
123 return td |
709
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
124 |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
125 # Try to load a theme specified in the configuration. |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
126 from piecrust.themes.base import ThemeLoader |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
127 loader = ThemeLoader(self.root_dir) |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
128 theme_dir = loader.getThemeDir() |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
129 if theme_dir is not None: |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
130 return theme_dir |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
131 |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
132 # Nothing... use the default theme. |
271
12657039c436
internal: Re-use the cached resource directory.
Ludovic Chabant <ludovic@chabant.com>
parents:
260
diff
changeset
|
133 return os.path.join(RESOURCES_DIR, 'theme') |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
134 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
135 @cached_property |
848
7d83b9484b98
plugins: Add support for "ad-hoc" local plugins.
Ludovic Chabant <ludovic@chabant.com>
parents:
815
diff
changeset
|
136 def plugins_dir(self): |
7d83b9484b98
plugins: Add support for "ad-hoc" local plugins.
Ludovic Chabant <ludovic@chabant.com>
parents:
815
diff
changeset
|
137 return self._get_dir(PLUGINS_DIR) |
7d83b9484b98
plugins: Add support for "ad-hoc" local plugins.
Ludovic Chabant <ludovic@chabant.com>
parents:
815
diff
changeset
|
138 |
7d83b9484b98
plugins: Add support for "ad-hoc" local plugins.
Ludovic Chabant <ludovic@chabant.com>
parents:
815
diff
changeset
|
139 @cached_property |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
140 def cache_dir(self): |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
141 return os.path.join(self.root_dir, CACHE_DIR, self.cache_key) |
371
c2ca72fb7f0b
caching: Use separate caches for config variants and other contexts.
Ludovic Chabant <ludovic@chabant.com>
parents:
369
diff
changeset
|
142 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
143 @cached_property |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
144 def sources(self): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
145 defs = {} |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
146 for cls in self.plugin_loader.getSources(): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
147 defs[cls.SOURCE_NAME] = cls |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
148 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
149 sources = [] |
5 | 150 for n, s in self.config.get('site/sources').items(): |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
151 cls = defs.get(s['type']) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
152 if cls is None: |
584
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
153 raise ConfigurationError("No such page source type: %s" % |
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
154 s['type']) |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
155 src = cls(self, n, s) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
156 sources.append(src) |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
157 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
158 return sources |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
159 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
160 @cached_property |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
161 def routes(self): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
162 routes = [] |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
163 for r in self.config.get('site/routes'): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
164 rte = Route(self, r) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
165 routes.append(rte) |
854
08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents:
853
diff
changeset
|
166 routes = sorted(routes, key=lambda r: r.pass_num) |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
167 return routes |
0 | 168 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
169 @cached_property |
758
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
170 def publishers(self): |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
171 defs_by_name = {} |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
172 defs_by_scheme = {} |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
173 for cls in self.plugin_loader.getPublishers(): |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
174 defs_by_name[cls.PUBLISHER_NAME] = cls |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
175 if cls.PUBLISHER_SCHEME: |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
176 defs_by_scheme[cls.PUBLISHER_SCHEME] = cls |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
177 |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
178 tgts = [] |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
179 publish_config = self.config.get('publish') |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
180 if publish_config is None: |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
181 return tgts |
885
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
876
diff
changeset
|
182 |
758
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
183 for n, t in publish_config.items(): |
885
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
876
diff
changeset
|
184 pub_class = None |
758
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
185 if isinstance(t, dict): |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
186 pub_type = t.get('type') |
885
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
876
diff
changeset
|
187 pub_class = defs_by_name[pub_type] |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
876
diff
changeset
|
188 pub_cfg = t |
758
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
189 elif isinstance(t, str): |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
190 comps = urllib.parse.urlparse(t) |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
191 pub_type = comps.scheme |
885
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
876
diff
changeset
|
192 pub_class = defs_by_scheme[pub_type] |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
876
diff
changeset
|
193 pub_cfg = None |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
876
diff
changeset
|
194 if pub_class is None: |
758
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
195 raise ConfigurationError("No such publisher: %s" % pub_type) |
885
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
876
diff
changeset
|
196 |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
876
diff
changeset
|
197 tgt = pub_class(self, n, pub_cfg) |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
876
diff
changeset
|
198 if pub_cfg is None: |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
876
diff
changeset
|
199 tgt.parseUrlTarget(comps) |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
876
diff
changeset
|
200 |
758
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
201 tgts.append(tgt) |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
202 return tgts |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
203 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
204 def getSource(self, source_name): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
205 for source in self.sources: |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
206 if source.name == source_name: |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
207 return source |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
208 |
853
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
209 from piecrust.sources.base import SourceNotFoundError |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
210 raise SourceNotFoundError(source_name) |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
211 |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
212 def getSourceRoute(self, source_name): |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
213 for route in self.routes: |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
214 if route.source_name == source_name: |
853
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
215 return route |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
216 |
853
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
217 from piecrust.routing import RouteNotFoundError |
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
218 raise RouteNotFoundError(source_name) |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
219 |
758
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
220 def getPublisher(self, target_name): |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
221 for pub in self.publishers: |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
222 if pub.target == target_name: |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
223 return pub |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
224 return None |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
225 |
853
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
226 def getPage(self, source, content_item): |
876
d1095774bfcf
refactor: Fix some issues with record/cache entry collisions, add counters.
Ludovic Chabant <ludovic@chabant.com>
parents:
854
diff
changeset
|
227 cache_key = '%s@%s' % (source.name, content_item.spec) |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
228 return self.env.page_repository.get( |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
229 cache_key, |
853
f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
852
diff
changeset
|
230 lambda: Page(source, content_item)) |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
231 |
0 | 232 def _get_dir(self, default_rel_dir): |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
233 abs_dir = os.path.join(self.root_dir, default_rel_dir) |
0 | 234 if os.path.isdir(abs_dir): |
235 return abs_dir | |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
236 return None |
0 | 237 |
238 def _get_configurable_dirs(self, default_rel_dir, conf_name): | |
239 dirs = [] | |
240 | |
241 # Add custom directories from the configuration. | |
242 conf_dirs = self.config.get(conf_name) | |
243 if conf_dirs is not None: | |
5 | 244 if isinstance(conf_dirs, str): |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
245 dirs.append(os.path.join(self.root_dir, conf_dirs)) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
246 else: |
56
2d617b889b00
Make template directories properly absolute.
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
247 dirs += [os.path.join(self.root_dir, p) for p in conf_dirs] |
0 | 248 |
249 # Add the default directory if it exists. | |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
250 default_dir = os.path.join(self.root_dir, default_rel_dir) |
0 | 251 if os.path.isdir(default_dir): |
252 dirs.append(default_dir) | |
253 | |
254 return dirs | |
255 | |
466
456db44dcc53
bake: Pass the config variants and values from the CLI to the baker.
Ludovic Chabant <ludovic@chabant.com>
parents:
419
diff
changeset
|
256 |
909
eed19a80c00e
chef: Allow multiple config variants to be applied.
Ludovic Chabant <ludovic@chabant.com>
parents:
904
diff
changeset
|
257 def apply_variants_and_values(app, config_variants=None, config_values=None): |
eed19a80c00e
chef: Allow multiple config variants to be applied.
Ludovic Chabant <ludovic@chabant.com>
parents:
904
diff
changeset
|
258 if config_variants is not None: |
eed19a80c00e
chef: Allow multiple config variants to be applied.
Ludovic Chabant <ludovic@chabant.com>
parents:
904
diff
changeset
|
259 for value in config_variants: |
eed19a80c00e
chef: Allow multiple config variants to be applied.
Ludovic Chabant <ludovic@chabant.com>
parents:
904
diff
changeset
|
260 logger.debug("Adding configuration variant '%s'." % value) |
eed19a80c00e
chef: Allow multiple config variants to be applied.
Ludovic Chabant <ludovic@chabant.com>
parents:
904
diff
changeset
|
261 variant_path = os.path.join( |
eed19a80c00e
chef: Allow multiple config variants to be applied.
Ludovic Chabant <ludovic@chabant.com>
parents:
904
diff
changeset
|
262 app.root_dir, 'configs', '%s.yml' % value) |
eed19a80c00e
chef: Allow multiple config variants to be applied.
Ludovic Chabant <ludovic@chabant.com>
parents:
904
diff
changeset
|
263 app.config.addVariant(variant_path) |
466
456db44dcc53
bake: Pass the config variants and values from the CLI to the baker.
Ludovic Chabant <ludovic@chabant.com>
parents:
419
diff
changeset
|
264 |
456db44dcc53
bake: Pass the config variants and values from the CLI to the baker.
Ludovic Chabant <ludovic@chabant.com>
parents:
419
diff
changeset
|
265 if config_values is not None: |
456db44dcc53
bake: Pass the config variants and values from the CLI to the baker.
Ludovic Chabant <ludovic@chabant.com>
parents:
419
diff
changeset
|
266 for name, value in config_values: |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
267 logger.debug("Adding configuration override '%s': %s" % |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
268 (name, value)) |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
269 app.config.addVariantValue(name, value) |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
270 |
466
456db44dcc53
bake: Pass the config variants and values from the CLI to the baker.
Ludovic Chabant <ludovic@chabant.com>
parents:
419
diff
changeset
|
271 |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
272 class PieCrustFactory(object): |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
273 """ A class that builds a PieCrust app instance. |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
274 """ |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
275 def __init__( |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
276 self, root_dir, *, |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
277 cache=True, cache_key=None, |
909
eed19a80c00e
chef: Allow multiple config variants to be applied.
Ludovic Chabant <ludovic@chabant.com>
parents:
904
diff
changeset
|
278 config_variants=None, config_values=None, |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
279 debug=False, theme_site=False): |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
280 self.root_dir = root_dir |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
281 self.cache = cache |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
282 self.cache_key = cache_key |
909
eed19a80c00e
chef: Allow multiple config variants to be applied.
Ludovic Chabant <ludovic@chabant.com>
parents:
904
diff
changeset
|
283 self.config_variants = config_variants |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
284 self.config_values = config_values |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
285 self.debug = debug |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
286 self.theme_site = theme_site |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
287 |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
288 def create(self): |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
289 app = PieCrust( |
852
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
290 self.root_dir, |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
291 cache=self.cache, |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
292 cache_key=self.cache_key, |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
293 debug=self.debug, |
4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
848
diff
changeset
|
294 theme_site=self.theme_site) |
909
eed19a80c00e
chef: Allow multiple config variants to be applied.
Ludovic Chabant <ludovic@chabant.com>
parents:
904
diff
changeset
|
295 apply_variants_and_values( |
eed19a80c00e
chef: Allow multiple config variants to be applied.
Ludovic Chabant <ludovic@chabant.com>
parents:
904
diff
changeset
|
296 app, self.config_variants, self.config_values) |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
297 return app |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
298 |