Revision e5b77cde
b/snf-pithos-backend/pithos/backends/modular.py | ||
---|---|---|
164 | 164 |
return wrapper |
165 | 165 |
|
166 | 166 |
|
167 |
def list_method(func): |
|
168 |
@wraps(func) |
|
169 |
def wrapper(self, *args, **kw): |
|
170 |
marker = kw.get('marker') |
|
171 |
limit = kw.get('limit') |
|
172 |
result = func(self, *args, **kw) |
|
173 |
start, limit = self._list_limits(result, marker, limit) |
|
174 |
return result[start:start + limit] |
|
175 |
return wrapper |
|
176 |
|
|
177 |
|
|
167 | 178 |
class ModularBackend(BaseBackend): |
168 | 179 |
"""A modular backend. |
169 | 180 |
|
... | ... | |
333 | 344 |
|
334 | 345 |
@debug_method |
335 | 346 |
@backend_method |
347 |
@list_method |
|
336 | 348 |
def list_accounts(self, user, marker=None, limit=10000): |
337 | 349 |
"""Return a list of accounts the user can access.""" |
338 | 350 |
|
339 |
allowed = self._allowed_accounts(user) |
|
340 |
start, limit = self._list_limits(allowed, marker, limit) |
|
341 |
return allowed[start:start + limit] |
|
351 |
return self._allowed_accounts(user) |
|
342 | 352 |
|
343 | 353 |
def _get_account_quotas(self, account): |
344 | 354 |
"""Get account usage from astakos.""" |
... | ... | |
490 | 500 |
|
491 | 501 |
@debug_method |
492 | 502 |
@backend_method |
503 |
@list_method |
|
493 | 504 |
def list_containers(self, user, account, marker=None, limit=10000, |
494 | 505 |
shared=False, until=None, public=False): |
495 | 506 |
"""Return a list of containers existing under an account.""" |
... | ... | |
497 | 508 |
if user != account: |
498 | 509 |
if until or account not in self._allowed_accounts(user): |
499 | 510 |
raise NotAllowedError |
500 |
allowed = self._allowed_containers(user, account) |
|
501 |
start, limit = self._list_limits(allowed, marker, limit) |
|
502 |
return allowed[start:start + limit] |
|
511 |
return self._allowed_containers(user, account) |
|
503 | 512 |
if shared or public: |
504 | 513 |
allowed = set() |
505 | 514 |
if shared: |
... | ... | |
508 | 517 |
if public: |
509 | 518 |
allowed.update([x[0].split('/', 2)[1] for x in |
510 | 519 |
self.permissions.public_list(account)]) |
511 |
allowed = sorted(allowed) |
|
512 |
start, limit = self._list_limits(allowed, marker, limit) |
|
513 |
return allowed[start:start + limit] |
|
520 |
return sorted(allowed) |
|
514 | 521 |
node = self.node.node_lookup(account) |
515 |
containers = [x[0] for x in self._list_object_properties(
|
|
522 |
return [x[0] for x in self._list_object_properties(
|
|
516 | 523 |
node, account, '', '/', marker, limit, False, None, [], until)] |
517 |
start, limit = self._list_limits( |
|
518 |
[x[0] for x in containers], marker, limit) |
|
519 |
return containers[start:start + limit] |
|
520 | 524 |
|
521 | 525 |
@debug_method |
522 | 526 |
@backend_method |
Also available in: Unified diff