Revision 90ee1eb3 snf-pithos-backend/pithos/backends/modular.py
b/snf-pithos-backend/pithos/backends/modular.py | ||
---|---|---|
313 | 313 |
self.permissions.group_destroy(account) |
314 | 314 |
|
315 | 315 |
@backend_method |
316 |
def list_containers(self, user, account, marker=None, limit=10000, shared=False, until=None): |
|
316 |
def list_containers(self, user, account, marker=None, limit=10000, shared=False, until=None, public=False):
|
|
317 | 317 |
"""Return a list of containers existing under an account.""" |
318 | 318 |
|
319 | 319 |
logger.debug("list_containers: %s %s %s %s %s", account, marker, limit, shared, until) |
... | ... | |
323 | 323 |
allowed = self._allowed_containers(user, account) |
324 | 324 |
start, limit = self._list_limits(allowed, marker, limit) |
325 | 325 |
return allowed[start:start + limit] |
326 |
if shared: |
|
327 |
allowed = [x.split('/', 2)[1] for x in self.permissions.access_list_shared(account)] |
|
326 |
if shared or public: |
|
327 |
allowed = [] |
|
328 |
if shared: |
|
329 |
allowed.extend([x.split('/', 2)[1] for x in self.permissions.access_list_shared(account)]) |
|
330 |
if public: |
|
331 |
allowed.extend([x[0].split('/', 2)[1] for x in self.permissions.public_list(account)]) |
|
328 | 332 |
allowed = list(set(allowed)) |
329 | 333 |
start, limit = self._list_limits(allowed, marker, limit) |
330 | 334 |
return allowed[start:start + limit] |
... | ... | |
461 | 465 |
self.node.node_remove(node) |
462 | 466 |
self._report_size_change(user, account, -size, {'action': 'container delete'}) |
463 | 467 |
|
464 |
def _list_objects(self, user, account, container, prefix, delimiter, marker, limit, virtual, domain, keys, shared, until, size_range, all_props): |
|
468 |
def _list_objects(self, user, account, container, prefix, delimiter, marker, limit, virtual, domain, keys, shared, until, size_range, all_props, public):
|
|
465 | 469 |
if user != account and until: |
466 | 470 |
raise NotAllowedError |
467 |
allowed = self._list_object_permissions(user, account, container, prefix, shared) |
|
468 |
if shared and not allowed:
|
|
471 |
allowed = self._list_object_permissions(user, account, container, prefix, shared, public)
|
|
472 |
if (shared or public) and not allowed:
|
|
469 | 473 |
return [] |
470 | 474 |
path, node = self._lookup_container(account, container) |
471 | 475 |
allowed = self._get_formatted_paths(allowed) |
472 | 476 |
return self._list_object_properties(node, path, prefix, delimiter, marker, limit, virtual, domain, keys, until, size_range, allowed, all_props) |
473 | 477 |
|
474 |
def _list_object_permissions(self, user, account, container, prefix, shared): |
|
478 |
def _list_object_permissions(self, user, account, container, prefix, shared, public):
|
|
475 | 479 |
allowed = [] |
476 | 480 |
path = '/'.join((account, container, prefix)).rstrip('/') |
477 | 481 |
if user != account: |
... | ... | |
481 | 485 |
else: |
482 | 486 |
if shared: |
483 | 487 |
allowed = self.permissions.access_list_shared(path) |
488 |
allowed.extend([x[0] for x in self.permissions.public_list(path)]) |
|
489 |
allowed = list(set(allowed)) |
|
484 | 490 |
if not allowed: |
485 | 491 |
return [] |
486 | 492 |
return allowed |
487 | 493 |
|
488 | 494 |
@backend_method |
489 |
def list_objects(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, domain=None, keys=[], shared=False, until=None, size_range=None): |
|
495 |
def list_objects(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, domain=None, keys=[], shared=False, until=None, size_range=None, public=False):
|
|
490 | 496 |
"""Return a list of object (name, version_id) tuples existing under a container.""" |
491 | 497 |
|
492 | 498 |
logger.debug("list_objects: %s %s %s %s %s %s %s %s %s %s %s %s", account, container, prefix, delimiter, marker, limit, virtual, domain, keys, shared, until, size_range) |
493 |
return self._list_objects(user, account, container, prefix, delimiter, marker, limit, virtual, domain, keys, shared, until, size_range, False) |
|
499 |
return self._list_objects(user, account, container, prefix, delimiter, marker, limit, virtual, domain, keys, shared, until, size_range, False, public)
|
|
494 | 500 |
|
495 | 501 |
@backend_method |
496 |
def list_object_meta(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, domain=None, keys=[], shared=False, until=None, size_range=None): |
|
502 |
def list_object_meta(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, domain=None, keys=[], shared=False, until=None, size_range=None, public=False):
|
|
497 | 503 |
"""Return a list of object metadata dicts existing under a container.""" |
498 | 504 |
|
499 | 505 |
logger.debug("list_object_meta: %s %s %s %s %s %s %s %s %s %s %s %s", account, container, prefix, delimiter, marker, limit, virtual, domain, keys, shared, until, size_range) |
500 |
props = self._list_objects(user, account, container, prefix, delimiter, marker, limit, virtual, domain, keys, shared, until, size_range, True) |
|
506 |
props = self._list_objects(user, account, container, prefix, delimiter, marker, limit, virtual, domain, keys, shared, until, size_range, True, public)
|
|
501 | 507 |
objects = [] |
502 | 508 |
for p in props: |
503 | 509 |
if len(p) == 2: |
... | ... | |
520 | 526 |
"""Return a list of paths that enforce permissions under a container.""" |
521 | 527 |
|
522 | 528 |
logger.debug("list_object_permissions: %s %s %s", account, container, prefix) |
523 |
return self._list_object_permissions(user, account, container, prefix, True) |
|
529 |
return self._list_object_permissions(user, account, container, prefix, True, False)
|
|
524 | 530 |
|
525 | 531 |
@backend_method |
526 | 532 |
def list_object_public(self, user, account, container, prefix=''): |
Also available in: Unified diff