# HG changeset patch # User Ludovic Chabant # Date 1532929931 25200 # Node ID 97b1b46cc1564aa44e32c330f776f58b439bdbe9 # Parent be74ba54a06f56833a2b9d3f677833473cb59964 config: Allow tweaking the configuration of default routes. diff -r be74ba54a06f -r 97b1b46cc156 piecrust/appconfig.py --- 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