Mercurial > piecrust2
annotate piecrust/app.py @ 851:2c7e57d80bba
optimize: Don't load Jinja unless we need to.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 29 Apr 2017 21:42:22 -0700 |
parents | 7d83b9484b98 |
children | 4850f8c21b6e 46025a1b5434 |
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 hashlib | |
4 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
|
5 import urllib.parse |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
6 from werkzeug.utils import cached_property |
271
12657039c436
internal: Re-use the cached resource directory.
Ludovic Chabant <ludovic@chabant.com>
parents:
260
diff
changeset
|
7 from piecrust import ( |
584
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
8 RESOURCES_DIR, |
36
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
9 CACHE_DIR, TEMPLATES_DIR, ASSETS_DIR, |
848
7d83b9484b98
plugins: Add support for "ad-hoc" local plugins.
Ludovic Chabant <ludovic@chabant.com>
parents:
815
diff
changeset
|
10 THEME_DIR, PLUGINS_DIR, |
584
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
11 CONFIG_PATH, THEME_CONFIG_PATH) |
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
12 from piecrust.appconfig import PieCrustConfiguration |
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
13 from piecrust.cache import ExtensibleCache, NullExtensibleCache |
758
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
14 from piecrust.configuration import ConfigurationError, merge_dicts |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
15 from piecrust.environment import StandardEnvironment |
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 |
584
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
18 from piecrust.sources.base import REALM_THEME |
0 | 19 |
20 | |
21 logger = logging.getLogger(__name__) | |
22 | |
23 | |
24 class PieCrust(object): | |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
25 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
|
26 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
|
27 self.root_dir = root_dir |
0 | 28 self.debug = debug |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
29 self.theme_site = theme_site |
0 | 30 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
|
31 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
|
32 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
33 if cache: |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
34 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
|
35 else: |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
36 self.cache = NullExtensibleCache() |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
37 |
0 | 38 self.env = env |
39 if self.env is None: | |
40 self.env = StandardEnvironment() | |
41 self.env.initialize(self) | |
411
e7b865f8f335
bake: Enable multiprocess baking.
Ludovic Chabant <ludovic@chabant.com>
parents:
371
diff
changeset
|
42 self.env.registerTimer('SiteConfigLoad') |
e7b865f8f335
bake: Enable multiprocess baking.
Ludovic Chabant <ludovic@chabant.com>
parents:
371
diff
changeset
|
43 self.env.registerTimer('PageLoad') |
419
6801ad5aa1d4
internal: Optimize page segments rendering.
Ludovic Chabant <ludovic@chabant.com>
parents:
415
diff
changeset
|
44 self.env.registerTimer("PageDataBuild") |
586
59268b4d8c71
bake: Add new performance timers.
Ludovic Chabant <ludovic@chabant.com>
parents:
584
diff
changeset
|
45 self.env.registerTimer("BuildRenderData") |
59268b4d8c71
bake: Add new performance timers.
Ludovic Chabant <ludovic@chabant.com>
parents:
584
diff
changeset
|
46 self.env.registerTimer("PageRender") |
59268b4d8c71
bake: Add new performance timers.
Ludovic Chabant <ludovic@chabant.com>
parents:
584
diff
changeset
|
47 self.env.registerTimer("PageRenderSegments") |
59268b4d8c71
bake: Add new performance timers.
Ludovic Chabant <ludovic@chabant.com>
parents:
584
diff
changeset
|
48 self.env.registerTimer("PageRenderLayout") |
59268b4d8c71
bake: Add new performance timers.
Ludovic Chabant <ludovic@chabant.com>
parents:
584
diff
changeset
|
49 self.env.registerTimer("PageSerialize") |
411
e7b865f8f335
bake: Enable multiprocess baking.
Ludovic Chabant <ludovic@chabant.com>
parents:
371
diff
changeset
|
50 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
51 @cached_property |
0 | 52 def config(self): |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
53 logger.debug("Creating site configuration...") |
411
e7b865f8f335
bake: Enable multiprocess baking.
Ludovic Chabant <ludovic@chabant.com>
parents:
371
diff
changeset
|
54 start_time = time.perf_counter() |
e7b865f8f335
bake: Enable multiprocess baking.
Ludovic Chabant <ludovic@chabant.com>
parents:
371
diff
changeset
|
55 |
663
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
586
diff
changeset
|
56 if not self.theme_site: |
681
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
57 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
|
58 else: |
681
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
59 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
|
60 |
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
61 theme_path = None |
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
62 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
|
63 theme_path = os.path.join(self.theme_dir, THEME_CONFIG_PATH) |
0 | 64 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
65 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
|
66 config = PieCrustConfiguration( |
681
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
67 path=path, theme_path=theme_path, |
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
68 cache=config_cache, theme_config=self.theme_site) |
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
69 |
805
fd694f1297c7
config: Cleanup config loading code. Add support for a `local.yml` config.
Ludovic Chabant <ludovic@chabant.com>
parents:
758
diff
changeset
|
70 local_path = os.path.join( |
fd694f1297c7
config: Cleanup config loading code. Add support for a `local.yml` config.
Ludovic Chabant <ludovic@chabant.com>
parents:
758
diff
changeset
|
71 self.root_dir, 'configs', 'local.yml') |
fd694f1297c7
config: Cleanup config loading code. Add support for a `local.yml` config.
Ludovic Chabant <ludovic@chabant.com>
parents:
758
diff
changeset
|
72 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
|
73 |
681
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
74 if self.theme_site: |
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
75 variant_path = os.path.join( |
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
76 self.root_dir, 'configs', 'theme_preview.yml') |
894d286b348f
internal: Refactor config loading some more.
Ludovic Chabant <ludovic@chabant.com>
parents:
675
diff
changeset
|
77 config.addVariant(variant_path, raise_if_not_found=False) |
0 | 78 |
411
e7b865f8f335
bake: Enable multiprocess baking.
Ludovic Chabant <ludovic@chabant.com>
parents:
371
diff
changeset
|
79 self.env.stepTimer('SiteConfigLoad', time.perf_counter() - start_time) |
0 | 80 return config |
81 | |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
82 @cached_property |
36
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
83 def assets_dirs(self): |
584
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
84 assets_dirs = self._get_configurable_dirs( |
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
85 ASSETS_DIR, 'site/assets_dirs') |
36
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
86 |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
87 # Also add the theme directory, if any. |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
88 if self.theme_dir: |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
89 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
|
90 if os.path.isdir(default_theme_dir): |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
91 assets_dirs.append(default_theme_dir) |
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 return assets_dirs |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
94 |
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
95 @cached_property |
0 | 96 def templates_dirs(self): |
584
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
97 templates_dirs = self._get_configurable_dirs( |
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
98 TEMPLATES_DIR, 'site/templates_dirs') |
0 | 99 |
36
485682a6de50
New site layout support.
Ludovic Chabant <ludovic@chabant.com>
parents:
31
diff
changeset
|
100 # Also, add the theme directory, if any. |
0 | 101 if self.theme_dir: |
102 default_theme_dir = os.path.join(self.theme_dir, TEMPLATES_DIR) | |
103 if os.path.isdir(default_theme_dir): | |
104 templates_dirs.append(default_theme_dir) | |
105 | |
106 return templates_dirs | |
107 | |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
108 @cached_property |
0 | 109 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
|
110 # 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
|
111 if self.theme_site: |
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
586
diff
changeset
|
112 return None |
709
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
113 |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
114 # 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
|
115 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
|
116 if td is not None: |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
117 return td |
709
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
118 |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
119 # 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
|
120 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
|
121 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
|
122 theme_dir = loader.getThemeDir() |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
123 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
|
124 return theme_dir |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
125 |
4285b2c9b872
themes: Add support for loading from a library of themes.
Ludovic Chabant <ludovic@chabant.com>
parents:
681
diff
changeset
|
126 # Nothing... use the default theme. |
271
12657039c436
internal: Re-use the cached resource directory.
Ludovic Chabant <ludovic@chabant.com>
parents:
260
diff
changeset
|
127 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
|
128 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
129 @cached_property |
848
7d83b9484b98
plugins: Add support for "ad-hoc" local plugins.
Ludovic Chabant <ludovic@chabant.com>
parents:
815
diff
changeset
|
130 def plugins_dir(self): |
7d83b9484b98
plugins: Add support for "ad-hoc" local plugins.
Ludovic Chabant <ludovic@chabant.com>
parents:
815
diff
changeset
|
131 return self._get_dir(PLUGINS_DIR) |
7d83b9484b98
plugins: Add support for "ad-hoc" local plugins.
Ludovic Chabant <ludovic@chabant.com>
parents:
815
diff
changeset
|
132 |
7d83b9484b98
plugins: Add support for "ad-hoc" local plugins.
Ludovic Chabant <ludovic@chabant.com>
parents:
815
diff
changeset
|
133 @cached_property |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
134 def cache_dir(self): |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
135 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
|
136 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
137 @cached_property |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
138 def sources(self): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
139 defs = {} |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
140 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
|
141 defs[cls.SOURCE_NAME] = cls |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
142 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
143 sources = [] |
5 | 144 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
|
145 cls = defs.get(s['type']) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
146 if cls is None: |
584
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
147 raise ConfigurationError("No such page source type: %s" % |
9ccc933ac2c7
internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
568
diff
changeset
|
148 s['type']) |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
149 src = cls(self, n, s) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
150 sources.append(src) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
151 return sources |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
152 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
153 @cached_property |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
154 def routes(self): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
155 routes = [] |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
156 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
|
157 rte = Route(self, r) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
158 routes.append(rte) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
159 return routes |
0 | 160 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
161 @cached_property |
711
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
162 def generators(self): |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
163 defs = {} |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
164 for cls in self.plugin_loader.getPageGenerators(): |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
165 defs[cls.GENERATOR_NAME] = cls |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
166 |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
167 gens = [] |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
168 for n, g in self.config.get('site/generators').items(): |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
169 cls = defs.get(g['type']) |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
170 if cls is None: |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
171 raise ConfigurationError("No such page generator type: %s" % |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
172 g['type']) |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
173 gen = cls(self, n, g) |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
174 gens.append(gen) |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
175 return gens |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
176 |
758
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
177 @cached_property |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
178 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
186 tgts = [] |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
187 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
|
188 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
|
189 return tgts |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
190 for n, t in publish_config.items(): |
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 = None |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
192 is_scheme = False |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
193 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
|
194 pub_type = t.get('type') |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
195 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
|
196 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
|
197 pub_type = comps.scheme |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
198 is_scheme = True |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
199 cls = (defs_by_scheme.get(pub_type) if is_scheme |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
200 else defs_by_name.get(pub_type)) |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
201 if cls is None: |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
202 raise ConfigurationError("No such publisher: %s" % pub_type) |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
203 tgt = cls(self, n, t) |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
204 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
|
205 return tgts |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
206 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
207 def getSource(self, source_name): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
208 for source in self.sources: |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
209 if source.name == source_name: |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
210 return source |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
211 return None |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
212 |
711
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
213 def getGenerator(self, generator_name): |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
214 for gen in self.generators: |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
215 if gen.name == generator_name: |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
216 return gen |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
217 return None |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
218 |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
219 def getSourceRoutes(self, source_name): |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
220 for route in self.routes: |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
221 if route.source_name == source_name: |
711
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
222 yield route |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
223 |
711
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
224 def getSourceRoute(self, source_name, route_metadata): |
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
225 for route in self.getSourceRoutes(source_name): |
369
4b1019bb2533
serve: Giant refactor to change how we handle data when serving pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
364
diff
changeset
|
226 if (route_metadata is None or |
4b1019bb2533
serve: Giant refactor to change how we handle data when serving pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
364
diff
changeset
|
227 route.matchesMetadata(route_metadata)): |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
228 return route |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
229 return None |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
230 |
711
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
231 def getGeneratorRoute(self, generator_name): |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
232 for route in self.routes: |
711
ab5c6a8ae90a
bake: Replace hard-coded taxonomy support with "generator" system.
Ludovic Chabant <ludovic@chabant.com>
parents:
709
diff
changeset
|
233 if route.generator_name == generator_name: |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
234 return route |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
235 return None |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
236 |
758
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
237 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
|
238 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
|
239 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
|
240 return pub |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
241 return None |
6abb436fea5b
publish: Make publisher more powerful and better exposed on the command line.
Ludovic Chabant <ludovic@chabant.com>
parents:
711
diff
changeset
|
242 |
0 | 243 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
|
244 abs_dir = os.path.join(self.root_dir, default_rel_dir) |
0 | 245 if os.path.isdir(abs_dir): |
246 return abs_dir | |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
1
diff
changeset
|
247 return None |
0 | 248 |
249 def _get_configurable_dirs(self, default_rel_dir, conf_name): | |
250 dirs = [] | |
251 | |
252 # Add custom directories from the configuration. | |
253 conf_dirs = self.config.get(conf_name) | |
254 if conf_dirs is not None: | |
5 | 255 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
|
256 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
|
257 else: |
56
2d617b889b00
Make template directories properly absolute.
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
258 dirs += [os.path.join(self.root_dir, p) for p in conf_dirs] |
0 | 259 |
260 # 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
|
261 default_dir = os.path.join(self.root_dir, default_rel_dir) |
0 | 262 if os.path.isdir(default_dir): |
263 dirs.append(default_dir) | |
264 | |
265 return dirs | |
266 | |
466
456db44dcc53
bake: Pass the config variants and values from the CLI to the baker.
Ludovic Chabant <ludovic@chabant.com>
parents:
419
diff
changeset
|
267 |
456db44dcc53
bake: Pass the config variants and values from the CLI to the baker.
Ludovic Chabant <ludovic@chabant.com>
parents:
419
diff
changeset
|
268 def apply_variant_and_values(app, config_variant=None, config_values=None): |
456db44dcc53
bake: Pass the config variants and values from the CLI to the baker.
Ludovic Chabant <ludovic@chabant.com>
parents:
419
diff
changeset
|
269 if config_variant is not None: |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
270 logger.debug("Adding configuration variant '%s'." % config_variant) |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
271 variant_path = os.path.join( |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
272 app.root_dir, 'configs', '%s.yml' % config_variant) |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
273 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
|
274 |
456db44dcc53
bake: Pass the config variants and values from the CLI to the baker.
Ludovic Chabant <ludovic@chabant.com>
parents:
419
diff
changeset
|
275 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
|
276 for name, value in config_values: |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
277 logger.debug("Adding configuration override '%s': %s" % (name, value)) |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
278 app.config.addVariantValue(name, value) |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
279 |
466
456db44dcc53
bake: Pass the config variants and values from the CLI to the baker.
Ludovic Chabant <ludovic@chabant.com>
parents:
419
diff
changeset
|
280 |
666
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
281 class PieCrustFactory(object): |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
282 def __init__( |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
283 self, root_dir, *, |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
284 cache=True, cache_key=None, |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
285 config_variant=None, config_values=None, |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
286 debug=False, theme_site=False): |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
287 self.root_dir = root_dir |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
288 self.cache = cache |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
289 self.cache_key = cache_key |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
290 self.config_variant = config_variant |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
291 self.config_values = config_values |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
292 self.debug = debug |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
293 self.theme_site = theme_site |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
294 |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
295 def create(self): |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
296 app = PieCrust( |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
297 self.root_dir, |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
298 cache=self.cache, |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
299 cache_key=self.cache_key, |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
300 debug=self.debug, |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
301 theme_site=self.theme_site) |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
302 apply_variant_and_values( |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
303 app, self.config_variant, self.config_values) |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
304 return app |
81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
Ludovic Chabant <ludovic@chabant.com>
parents:
663
diff
changeset
|
305 |