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