Revision cf4a7a7b snf-pithos-backend/pithos/backends/modular.py
b/snf-pithos-backend/pithos/backends/modular.py | ||
---|---|---|
334 | 334 |
start, limit = self._list_limits(allowed, marker, limit) |
335 | 335 |
return allowed[start:start + limit] |
336 | 336 |
node = self.node.node_lookup(account) |
337 |
return [x[0] for x in self._list_object_properties(node, account, '', '/', marker, limit, False, None, [], until)] |
|
337 |
containers = [x[0] for x in self._list_object_properties(node, account, '', '/', marker, limit, False, None, [], until)] |
|
338 |
start, limit = self._list_limits([x[0] for x in containers], marker, limit) |
|
339 |
return containers[start:start + limit] |
|
338 | 340 |
|
339 | 341 |
@backend_method |
340 | 342 |
def list_container_meta(self, user, account, container, domain, until=None): |
... | ... | |
469 | 471 |
def _list_objects(self, user, account, container, prefix, delimiter, marker, limit, virtual, domain, keys, shared, until, size_range, all_props, public): |
470 | 472 |
if user != account and until: |
471 | 473 |
raise NotAllowedError |
474 |
if shared and public: |
|
475 |
# get shared first |
|
476 |
shared = self._list_object_permissions(user, account, container, prefix, shared=True, public=False) |
|
477 |
objects = [] |
|
478 |
if shared: |
|
479 |
path, node = self._lookup_container(account, container) |
|
480 |
shared = self._get_formatted_paths(shared) |
|
481 |
objects = self._list_object_properties(node, path, prefix, delimiter, marker, limit, virtual, domain, keys, until, size_range, shared, all_props) |
|
482 |
|
|
483 |
# get public |
|
484 |
objects.extend(self._list_public_object_properties(user, account, container, prefix, all_props)) |
|
485 |
|
|
486 |
objects.sort(key=lambda x: x[0]) |
|
487 |
start, limit = self._list_limits([x[0] for x in objects], marker, limit) |
|
488 |
return objects[start:start + limit] |
|
489 |
elif public: |
|
490 |
objects = self._list_public_object_properties(user, account, container, prefix, all_props) |
|
491 |
start, limit = self._list_limits([x[0] for x in objects], marker, limit) |
|
492 |
return objects[start:start + limit] |
|
493 |
|
|
472 | 494 |
allowed = self._list_object_permissions(user, account, container, prefix, shared, public) |
473 |
if (shared or public) and not allowed:
|
|
495 |
if shared and not allowed:
|
|
474 | 496 |
return [] |
475 | 497 |
path, node = self._lookup_container(account, container) |
476 | 498 |
allowed = self._get_formatted_paths(allowed) |
477 |
return self._list_object_properties(node, path, prefix, delimiter, marker, limit, virtual, domain, keys, until, size_range, allowed, all_props) |
|
499 |
objects = self._list_object_properties(node, path, prefix, delimiter, marker, limit, virtual, domain, keys, until, size_range, allowed, all_props) |
|
500 |
start, limit = self._list_limits([x[0] for x in objects], marker, limit) |
|
501 |
return objects[start:start + limit] |
|
478 | 502 |
|
503 |
def _list_public_object_properties(self, user, account, container, prefix, all_props): |
|
504 |
public = self._list_object_permissions(user, account, container, prefix, shared=False, public=True) |
|
505 |
paths, nodes = self._lookup_objects(public) |
|
506 |
path = '/'.join((account, container)) |
|
507 |
cont_prefix = path + '/' |
|
508 |
paths = [x[len(cont_prefix):] for x in paths] |
|
509 |
props = self.node.version_lookup_bulk(nodes, all_props=all_props) |
|
510 |
objects = [(path,) + props for path, props in zip(paths, props)] |
|
511 |
return objects |
|
512 |
|
|
479 | 513 |
def _list_objects_no_limit(self, user, account, container, prefix, delimiter, virtual, domain, keys, shared, until, size_range, all_props, public): |
480 | 514 |
objects = [] |
481 | 515 |
while True: |
... | ... | |
944 | 978 |
raise NameError('Object does not exist') |
945 | 979 |
return path, node |
946 | 980 |
|
981 |
def _lookup_objects(self, paths): |
|
982 |
nodes = self.node.node_lookup_bulk(paths) |
|
983 |
if nodes is None: |
|
984 |
raise NameError('Object does not exist') |
|
985 |
return paths, nodes |
|
986 |
|
|
947 | 987 |
def _get_properties(self, node, until=None): |
948 | 988 |
"""Return properties until the timestamp given.""" |
949 | 989 |
|
... | ... | |
1074 | 1114 |
objects.extend([(p, None) for p in prefixes] if virtual else []) |
1075 | 1115 |
objects.sort(key=lambda x: x[0]) |
1076 | 1116 |
objects = [(x[0][len(cont_prefix):],) + x[1:] for x in objects] |
1117 |
return objects |
|
1077 | 1118 |
|
1078 |
start, limit = self._list_limits([x[0] for x in objects], marker, limit) |
|
1079 |
return objects[start:start + limit] |
|
1080 |
|
|
1081 | 1119 |
# Reporting functions. |
1082 | 1120 |
|
1083 | 1121 |
def _report_size_change(self, user, account, size, details={}): |
Also available in: Unified diff