1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 08:04:49 +01:00

config: allow custom config.yaml settings for automatic collections.

settings in config.yaml are merged with collection-specific settings, which take precedence
(before, the config.yaml settings were being overwritten) #103
This commit is contained in:
Ilya Kreymer 2015-05-14 18:57:59 -07:00
parent 661678cf2d
commit 375072a56b
2 changed files with 16 additions and 7 deletions

View File

@ -1,6 +1,7 @@
import pkgutil
import mimetypes
import time
import logging
from datetime import datetime
@ -144,6 +145,7 @@ class WBHandler(SearchPageWbUrlHandler):
def resolve_refs(self, handler_dict):
if self.fallback_name:
self.fallback_handler = handler_dict.get(self.fallback_name)
logging.debug('Fallback Handler: ' + self.fallback_name)
def handle_request(self, wbrequest):
cdx_lines, output = self.index_reader.load_for_request(wbrequest)

View File

@ -124,8 +124,9 @@ def create_cdx_server_app(passed_config):
# collections based on file system
if config.get('enable_auto_colls', True):
colls_loader_cls = config.get('colls_loader_cls', DirectoryCollsLoader)
dir_loader = colls_loader_cls(config, static_routes)
collections.update(dir_loader())
dir_loader = colls_loader_cls(config, static_routes, collections)
dir_loader()
#collections.update(dir_loader())
routes = []
@ -142,12 +143,13 @@ def create_cdx_server_app(passed_config):
#=================================================================
class DirectoryCollsLoader(object):
def __init__(self, config, static_routes):
def __init__(self, config, static_routes, colls):
self.config = config
self.static_routes = static_routes
self.colls = colls
def __call__(self):
colls = {}
colls = self.colls
static_dir = self.config.get('paths')['static_path']
static_shared_prefix = self.config.get('static_shared_prefix')
@ -167,7 +169,11 @@ class DirectoryCollsLoader(object):
coll_config = self.load_coll_dir(full, name)
if coll_config:
colls[name] = coll_config
# if already exists, override existing config with coll specific
if name in colls:
colls[name].update(coll_config)
else:
colls[name] = coll_config
return colls
@ -263,8 +269,9 @@ def create_wb_router(passed_config=None):
# collections based on file system
if config.get('enable_auto_colls', True):
colls_loader_cls = config.get('colls_loader_cls', DirectoryCollsLoader)
dir_loader = colls_loader_cls(config, static_routes)
collections.update(dir_loader())
dir_loader = colls_loader_cls(config, static_routes, collections)
dir_loader()
#collections.update(dir_loader())
if config.get('enable_memento', False):
request_class = MementoRequest