Mercurial > piecrust2
changeset 1150:97b1b46cc156
config: Allow tweaking the configuration of default routes.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 29 Jul 2018 22:52:11 -0700 |
parents | be74ba54a06f |
children | 0d699f04968c |
files | piecrust/appconfig.py |
diffstat | 1 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/appconfig.py Tue Jul 10 21:03:58 2018 -0700 +++ b/piecrust/appconfig.py Sun Jul 29 22:52:11 2018 -0700 @@ -246,7 +246,11 @@ theme_site=self.theme_config) merge_dicts(values, blog_cfg) + for route in dcm['site']['routes']: + values + # Merge the site config into the result config. + _merge_route_configs(values, site_values) merge_dicts(values, site_values) def _validateAll(self, values): @@ -281,6 +285,18 @@ return values +def _merge_route_configs(values, from_default): + actual_routes = values.get('site', {}).get('routes', []) + default_routes = from_default.get('site', {}).get('routes', []) + for dr in list(default_routes): # copy because we'll trim it as we go. + ar = next((i for i in actual_routes + if i.get('source') == dr['source']), + None) + if ar is not None: + merge_dicts(ar, dr) + default_routes.remove(dr) + + class _ConfigCacheWriter(object): def __init__(self, cache_dict): self._cache_dict = cache_dict