Revision a8326bef pithos/api/functions.py
b/pithos/api/functions.py | ||
---|---|---|
189 | 189 |
except NotAllowedError: |
190 | 190 |
raise Unauthorized('Access denied') |
191 | 191 |
|
192 |
validate_modification_preconditions(request, meta) |
|
193 |
|
|
192 | 194 |
response = HttpResponse(status=204) |
193 | 195 |
put_account_headers(response, meta, groups) |
194 | 196 |
return response |
... | ... | |
303 | 305 |
except NameError: |
304 | 306 |
raise ItemNotFound('Container does not exist') |
305 | 307 |
|
308 |
validate_modification_preconditions(request, meta) |
|
309 |
|
|
306 | 310 |
response = HttpResponse(status=204) |
307 | 311 |
put_container_headers(response, meta, policy) |
308 | 312 |
return response |
... | ... | |
322 | 326 |
ret = 201 |
323 | 327 |
except NotAllowedError: |
324 | 328 |
raise Unauthorized('Access denied') |
329 |
except ValueError: |
|
330 |
raise BadRequest('Invalid policy header') |
|
325 | 331 |
except NameError: |
326 | 332 |
ret = 202 |
327 | 333 |
|
... | ... | |
519 | 525 |
update_sharing_meta(permissions, v_account, v_container, v_object, meta) |
520 | 526 |
update_public_meta(public, meta) |
521 | 527 |
|
528 |
# Evaluate conditions. |
|
529 |
validate_modification_preconditions(request, meta) |
|
530 |
try: |
|
531 |
validate_matching_preconditions(request, meta) |
|
532 |
except NotModified: |
|
533 |
response = HttpResponse(status=304) |
|
534 |
response['ETag'] = meta['hash'] |
|
535 |
return response |
|
536 |
|
|
522 | 537 |
response = HttpResponse(status=200) |
523 | 538 |
put_object_headers(response, meta) |
524 | 539 |
return response |
... | ... | |
652 | 667 |
if not request.GET.get('format'): |
653 | 668 |
request.serialization = 'text' |
654 | 669 |
|
670 |
# Evaluate conditions. |
|
671 |
if request.META.get('HTTP_IF_MATCH') or request.META.get('HTTP_IF_NONE_MATCH'): |
|
672 |
try: |
|
673 |
meta = backend.get_object_meta(request.user, v_account, v_container, v_object) |
|
674 |
except NotAllowedError: |
|
675 |
raise Unauthorized('Access denied') |
|
676 |
except NameError: |
|
677 |
meta = {} |
|
678 |
validate_matching_preconditions(request, meta) |
|
679 |
|
|
655 | 680 |
copy_from = request.META.get('HTTP_X_COPY_FROM') |
656 | 681 |
move_from = request.META.get('HTTP_X_MOVE_FROM') |
657 | 682 |
if copy_from or move_from: |
... | ... | |
800 | 825 |
dest_container, dest_name = split_container_object_string(dest_path) |
801 | 826 |
except ValueError: |
802 | 827 |
raise BadRequest('Invalid Destination header') |
828 |
|
|
829 |
# Evaluate conditions. |
|
830 |
if request.META.get('HTTP_IF_MATCH') or request.META.get('HTTP_IF_NONE_MATCH'): |
|
831 |
src_version = request.META.get('HTTP_X_SOURCE_VERSION') |
|
832 |
try: |
|
833 |
meta = backend.get_object_meta(request.user, v_account, v_container, v_object, src_version) |
|
834 |
except NotAllowedError: |
|
835 |
raise Unauthorized('Access denied') |
|
836 |
except (NameError, IndexError): |
|
837 |
raise ItemNotFound('Container or object does not exist') |
|
838 |
validate_matching_preconditions(request, meta) |
|
839 |
|
|
803 | 840 |
copy_or_move_object(request, v_account, v_container, v_object, dest_container, dest_name, move=False) |
804 | 841 |
return HttpResponse(status=201) |
805 | 842 |
|
... | ... | |
818 | 855 |
dest_container, dest_name = split_container_object_string(dest_path) |
819 | 856 |
except ValueError: |
820 | 857 |
raise BadRequest('Invalid Destination header') |
858 |
|
|
859 |
# Evaluate conditions. |
|
860 |
if request.META.get('HTTP_IF_MATCH') or request.META.get('HTTP_IF_NONE_MATCH'): |
|
861 |
try: |
|
862 |
meta = backend.get_object_meta(request.user, v_account, v_container, v_object) |
|
863 |
except NotAllowedError: |
|
864 |
raise Unauthorized('Access denied') |
|
865 |
except NameError: |
|
866 |
raise ItemNotFound('Container or object does not exist') |
|
867 |
validate_matching_preconditions(request, meta) |
|
868 |
|
|
821 | 869 |
copy_or_move_object(request, v_account, v_container, v_object, dest_container, dest_name, move=True) |
822 | 870 |
return HttpResponse(status=201) |
823 | 871 |
|
... | ... | |
840 | 888 |
raise Unauthorized('Access denied') |
841 | 889 |
except NameError: |
842 | 890 |
raise ItemNotFound('Object does not exist') |
891 |
|
|
892 |
# Evaluate conditions. |
|
893 |
if request.META.get('HTTP_IF_MATCH') or request.META.get('HTTP_IF_NONE_MATCH'): |
|
894 |
validate_matching_preconditions(request, prev_meta) |
|
895 |
|
|
843 | 896 |
# If replacing, keep previous values of 'Content-Type' and 'hash'. |
844 | 897 |
replace = True |
845 | 898 |
if 'update' in request.GET: |
Also available in: Unified diff