Merge "cfg: allow attribute access"
This commit is contained in:
@@ -21,6 +21,18 @@ class Config(dict):
|
||||
if base is not None:
|
||||
self.update(base)
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name not in self:
|
||||
raise AttributeError("No attribute '%s'" % name)
|
||||
|
||||
return self[name]
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
self[name] = value
|
||||
|
||||
def __delattr__(self, name):
|
||||
del self[name]
|
||||
|
||||
def update(self, other):
|
||||
if hasattr(other, 'keys'):
|
||||
for key in other.keys():
|
||||
|
||||
@@ -50,8 +50,8 @@ class BucketController(Controller):
|
||||
if req.params.get('max-keys').isdigit() is False:
|
||||
raise InvalidArgument('max-keys', req.params['max-keys'])
|
||||
|
||||
max_keys = int(req.params.get('max-keys', CONF['max_bucket_listing']))
|
||||
max_keys = min(max_keys, CONF['max_bucket_listing'])
|
||||
max_keys = int(req.params.get('max-keys', CONF.max_bucket_listing))
|
||||
max_keys = min(max_keys, CONF.max_bucket_listing)
|
||||
|
||||
query = {
|
||||
'format': 'json',
|
||||
@@ -132,7 +132,7 @@ class BucketController(Controller):
|
||||
LOGGER.debug(e)
|
||||
raise MalformedXML()
|
||||
|
||||
if location != CONF.get('location'):
|
||||
if location != CONF.location:
|
||||
# Swift3 cannot support multiple reagions now.
|
||||
raise InvalidLocationConstraint()
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ class LocationController(Controller):
|
||||
req.get_response(self.app, method='HEAD')
|
||||
|
||||
elem = Element('LocationConstraint')
|
||||
if CONF['location'] != 'US':
|
||||
elem.text = CONF['location']
|
||||
if CONF.location != 'US':
|
||||
elem.text = CONF.location
|
||||
body = tostring(elem)
|
||||
|
||||
return HTTPOk(body=body, content_type='application/xml')
|
||||
|
||||
@@ -75,7 +75,7 @@ class Request(swob.Request):
|
||||
self.environ['swift.leave_relative_location'] = True
|
||||
|
||||
def _parse_host(self):
|
||||
storage_domain = CONF['storage_domain']
|
||||
storage_domain = CONF.storage_domain
|
||||
if not storage_domain:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user