From a7307a6d98e22c114286a0e5f8a798c802617cef Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Wed, 25 Mar 2015 09:36:00 -0700 Subject: [PATCH] pywb_init: auto-collections init: inherit shared archive_paths, if any are set in main config.yaml --- pywb/webapp/pywb_init.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pywb/webapp/pywb_init.py b/pywb/webapp/pywb_init.py index 85272fd7..341fbb53 100644 --- a/pywb/webapp/pywb_init.py +++ b/pywb/webapp/pywb_init.py @@ -24,7 +24,7 @@ import logging #================================================================= -class DictChain: +class DictChain(object): def __init__(self, *dicts): self.dicts = dicts @@ -35,6 +35,12 @@ class DictChain: return val return default_val + def __contains__(self, key): + return self.get(key) is not None + + def __setitem__(self, key, value): + self.dicts[0][key] = value + #================================================================= def create_wb_handler(query_handler, config): @@ -199,7 +205,10 @@ class DirectoryCollsLoader(object): coll_config['metadata'] = metadata self._add_dir_if_exists(coll_config, root_dir, 'index_paths', True) - self._add_dir_if_exists(coll_config, root_dir, 'archive_paths', True) + + # inherit these properties from base, in case archive_paths is shared + shared_config = DictChain(coll_config, self.config) + self._add_dir_if_exists(shared_config, root_dir, 'archive_paths', True) if self._add_dir_if_exists(coll_config, root_dir, 'static_path', False): self.static_routes['static/' + name] = coll_config['static_path']