Revision 56f3c759 snf-pithos-backend/pithos/backends/modular.py
b/snf-pithos-backend/pithos/backends/modular.py | ||
---|---|---|
84 | 84 |
DEFAULT_BLOCK_PARAMS = { 'mappool': None, 'blockpool': None } |
85 | 85 |
#DEFAULT_QUEUE_HOSTS = '[amqp://guest:guest@localhost:5672]' |
86 | 86 |
#DEFAULT_QUEUE_EXCHANGE = 'pithos' |
87 |
DEFAULT_ALPHABET = ('0123456789' |
|
88 |
'abcdefghijklmnopqrstuvwxyz' |
|
89 |
'ABCDEFGHIJKLMNOPQRSTUVWXYZ') |
|
90 |
DEFAULT_MIN_LENGTH = 8 |
|
87 | 91 |
|
88 | 92 |
QUEUE_MESSAGE_KEY_PREFIX = 'pithos.%s' |
89 | 93 |
QUEUE_CLIENT_ID = 'pithos' |
... | ... | |
148 | 152 |
quotaholder_enabled=False, |
149 | 153 |
quotaholder_url=None, quotaholder_token=None, |
150 | 154 |
quotaholder_client_poolsize=None, |
151 |
free_versioning=True, block_params=None): |
|
155 |
free_versioning=True, block_params=None, |
|
156 |
public_url_min_length=None, |
|
157 |
public_url_alphabet=None): |
|
152 | 158 |
db_module = db_module or DEFAULT_DB_MODULE |
153 | 159 |
db_connection = db_connection or DEFAULT_DB_CONNECTION |
154 | 160 |
block_module = block_module or DEFAULT_BLOCK_MODULE |
... | ... | |
161 | 167 |
#queue_hosts = queue_hosts or DEFAULT_QUEUE_HOSTS |
162 | 168 |
#queue_exchange = queue_exchange or DEFAULT_QUEUE_EXCHANGE |
163 | 169 |
|
170 |
self.public_url_min_length = public_url_min_length or DEFAULT_MIN_LENGTH |
|
171 |
self.public_url_alphabet = public_url_alphabet or DEFAULT_ALPHABET |
|
172 |
|
|
164 | 173 |
self.hash_algorithm = 'sha256' |
165 | 174 |
self.block_size = 4 * 1024 * 1024 # 4MB |
166 | 175 |
self.free_versioning = free_versioning |
... | ... | |
718 | 727 |
account, container, prefix) |
719 | 728 |
public = {} |
720 | 729 |
for path, p in self.permissions.public_list('/'.join((account, container, prefix))): |
721 |
public[path] = p + ULTIMATE_ANSWER
|
|
730 |
public[path] = p |
|
722 | 731 |
return public |
723 | 732 |
|
724 | 733 |
@backend_method |
... | ... | |
815 | 824 |
self._can_read(user, account, container, name) |
816 | 825 |
path = self._lookup_object(account, container, name)[0] |
817 | 826 |
p = self.permissions.public_get(path) |
818 |
if p is not None: |
|
819 |
p += ULTIMATE_ANSWER |
|
820 | 827 |
return p |
821 | 828 |
|
822 | 829 |
@backend_method |
... | ... | |
830 | 837 |
if not public: |
831 | 838 |
self.permissions.public_unset(path) |
832 | 839 |
else: |
833 |
self.permissions.public_set(path) |
|
840 |
self.permissions.public_set( |
|
841 |
path, self.public_url_min_length, self.public_url_alphabet |
|
842 |
) |
|
834 | 843 |
|
835 | 844 |
@backend_method |
836 | 845 |
def get_object_hashmap(self, user, account, container, name, version=None): |
... | ... | |
1097 | 1106 |
"""Return the (account, container, name) for the public id given.""" |
1098 | 1107 |
|
1099 | 1108 |
logger.debug("get_public: %s %s", user, public) |
1100 |
if public is None or public < ULTIMATE_ANSWER: |
|
1101 |
raise NameError |
|
1102 |
path = self.permissions.public_path(public - ULTIMATE_ANSWER) |
|
1109 |
path = self.permissions.public_path(public) |
|
1103 | 1110 |
if path is None: |
1104 | 1111 |
raise NameError |
1105 | 1112 |
account, container, name = path.split('/', 2) |
Also available in: Unified diff