diff options
-rw-r--r-- | custodia.conf | 2 | ||||
-rwxr-xr-x | custodia/custodia | 10 | ||||
-rw-r--r-- | custodia/httpd/consumer.py | 3 |
3 files changed, 14 insertions, 1 deletions
diff --git a/custodia.conf b/custodia.conf index f7a1701..eb8d23e 100644 --- a/custodia.conf +++ b/custodia.conf @@ -18,4 +18,4 @@ table = secrets [/] handler = custodia.root.Root - +store = simple diff --git a/custodia/custodia b/custodia/custodia index 63b917c..d062790 100755 --- a/custodia/custodia +++ b/custodia/custodia @@ -9,6 +9,7 @@ except ImportError: from custodia.httpd.server import LocalHTTPServer import importlib import os +import six import sys @@ -75,6 +76,15 @@ def parse_config(cfgfile): hconf[opt] = val config[menu][name] = handler(hconf) + # Attach stores to consumers + for name, c in six.iteritems(config['consumers']): + if c.store_name is not None: + try: + c.store = config['stores'][c.store_name] + except KeyError: + raise ValueError('Consumer "%s" references unexisting ' + 'store "%s"' % (name, c.store_name)) + return config diff --git a/custodia/httpd/consumer.py b/custodia/httpd/consumer.py index 1947b29..700c4f8 100644 --- a/custodia/httpd/consumer.py +++ b/custodia/httpd/consumer.py @@ -10,6 +10,9 @@ class HTTPConsumer(object): def __init__(self, config=None): self.config = config + self.store_name = None + if config and 'store' in config: + self.store_name = config['store'] def handle(self, request): command = request.get('command', 'GET') |