Commit c24ac658 authored by Georgios D. Tsoukalas's avatar Georgios D. Tsoukalas
Browse files

minor refactor object_list for clarity

parent 6b75d4bf
...@@ -646,9 +646,9 @@ def object_list(request, v_account, v_container): ...@@ -646,9 +646,9 @@ def object_list(request, v_account, v_container):
shared = False shared = False
if 'shared' in request.GET: if 'shared' in request.GET:
shared = True shared = True
public = False
if request.user_uniq == v_account and 'public' in request.GET: public_requested = 'public' in request.GET
public = True public_granted = public_requested and request.user_uniq == v_account
if request.serialization == 'text': if request.serialization == 'text':
try: try:
...@@ -656,7 +656,7 @@ def object_list(request, v_account, v_container): ...@@ -656,7 +656,7 @@ def object_list(request, v_account, v_container):
request.user_uniq, v_account, request.user_uniq, v_account,
v_container, prefix, delimiter, marker, v_container, prefix, delimiter, marker,
limit, virtual, 'pithos', keys, shared, limit, virtual, 'pithos', keys, shared,
until, None, public) until, None, public_granted)
except NotAllowedError: except NotAllowedError:
raise Forbidden('Not allowed') raise Forbidden('Not allowed')
except ItemNotExists: except ItemNotExists:
...@@ -674,7 +674,7 @@ def object_list(request, v_account, v_container): ...@@ -674,7 +674,7 @@ def object_list(request, v_account, v_container):
objects = request.backend.list_object_meta( objects = request.backend.list_object_meta(
request.user_uniq, v_account, request.user_uniq, v_account,
v_container, prefix, delimiter, marker, v_container, prefix, delimiter, marker,
limit, virtual, 'pithos', keys, shared, until, None, public) limit, virtual, 'pithos', keys, shared, until, None, public_granted)
object_permissions = {} object_permissions = {}
object_public = {} object_public = {}
if until is None: if until is None:
...@@ -690,9 +690,12 @@ def object_list(request, v_account, v_container): ...@@ -690,9 +690,12 @@ def object_list(request, v_account, v_container):
object = x[name_idx:] object = x[name_idx:]
object_permissions[object] = request.backend.get_object_permissions( object_permissions[object] = request.backend.get_object_permissions(
request.user_uniq, v_account, v_container, object) request.user_uniq, v_account, v_container, object)
for k, v in request.backend.list_object_public(request.user_uniq,
v_account, v_container, prefix).iteritems(): if public_granted:
object_public[k[name_idx:]] = v for k, v in request.backend.list_object_public(
request.user_uniq, v_account,
v_container, prefix).iteritems():
object_public[k[name_idx:]] = v
except NotAllowedError: except NotAllowedError:
raise Forbidden('Not allowed') raise Forbidden('Not allowed')
except ItemNotExists: except ItemNotExists:
...@@ -729,9 +732,9 @@ def object_list(request, v_account, v_container): ...@@ -729,9 +732,9 @@ def object_list(request, v_account, v_container):
if permissions: if permissions:
update_sharing_meta(request, permissions, v_account, update_sharing_meta(request, permissions, v_account,
v_container, meta['name'], meta) v_container, meta['name'], meta)
public = object_public.get(meta['name'], None) public_url = object_public.get(meta['name'], None)
if public and request.user_uniq == v_account: if public_granted:
update_public_meta(public, meta) update_public_meta(public_url, meta)
object_meta.append(printable_header_dict(meta)) object_meta.append(printable_header_dict(meta))
if request.serialization == 'xml': if request.serialization == 'xml':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment