diff --git a/etc/proxy-server.conf-sample b/etc/proxy-server.conf-sample index 3d59c52d..636da064 100644 --- a/etc/proxy-server.conf-sample +++ b/etc/proxy-server.conf-sample @@ -29,6 +29,10 @@ use = egg:swift3#swift3 # GET Bucket location API. # location = US # +# Set the default maximum number of objects returned in the GET Bucket +# response. +# max_bucket_listing = 1000 +# # Specify a host name of your Swift cluster. This enables virtual-hosted style # requests. # storage_domain = diff --git a/swift3/cfg.py b/swift3/cfg.py index 35c067ae..ac94b6cc 100644 --- a/swift3/cfg.py +++ b/swift3/cfg.py @@ -16,5 +16,6 @@ # Global config dictionary. The default values can be defined here. CONF = { 'location': 'US', + 'max_bucket_listing': 1000, 'storage_domain': '', } diff --git a/swift3/controllers/bucket.py b/swift3/controllers/bucket.py index e6854557..cb3b209e 100644 --- a/swift3/controllers/bucket.py +++ b/swift3/controllers/bucket.py @@ -22,7 +22,7 @@ from swift3.controllers.acl import add_canonical_user, swift_acl_translate from swift3.etree import Element, SubElement, tostring from swift3.response import HTTPOk, S3NotImplemented, InvalidArgument -MAX_BUCKET_LISTING = 1000 +from swift3.cfg import CONF class BucketController(Controller): @@ -45,8 +45,8 @@ class BucketController(Controller): if req.params.get('max-keys').isdigit() is False: raise InvalidArgument('max-keys', req.params['max-keys']) - max_keys = min(int(req.params.get('max-keys', MAX_BUCKET_LISTING)), - 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', diff --git a/swift3/middleware.py b/swift3/middleware.py index f1ce13da..8e81112d 100644 --- a/swift3/middleware.py +++ b/swift3/middleware.py @@ -61,8 +61,6 @@ from swift3.request import Request from swift3.response import ErrorResponse, InternalError, MethodNotAllowed from swift3.cfg import CONF -MAX_BUCKET_LISTING = 1000 - # List of sub-resources that must be maintained as part of the HMAC # signature string. ALLOWED_SUB_RESOURCES = sorted([