diff options
author | Simo Sorce <simo@redhat.com> | 2015-03-25 15:57:59 -0400 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2015-03-25 15:57:59 -0400 |
commit | 2cae3084f806990af51b68370a0c8793a1e033b1 (patch) | |
tree | 4ab5668f640e0e61ef5318c03e57112f6370ac48 /custodia | |
parent | d40890b01fb600f09127cff0285472dfbba30442 (diff) | |
download | custodia-2cae3084f806990af51b68370a0c8793a1e033b1.tar.gz custodia-2cae3084f806990af51b68370a0c8793a1e033b1.tar.xz custodia-2cae3084f806990af51b68370a0c8793a1e033b1.zip |
Make stores directly availble to consumers
Diffstat (limited to 'custodia')
-rwxr-xr-x | custodia/custodia | 10 | ||||
-rw-r--r-- | custodia/httpd/consumer.py | 3 |
2 files changed, 13 insertions, 0 deletions
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') |