Revision 79bb41b7 pithos/api/functions.py
b/pithos/api/functions.py | ||
---|---|---|
728 | 728 |
if copy_from or move_from: |
729 | 729 |
content_length = get_content_length(request) # Required by the API. |
730 | 730 |
|
731 |
src_account = smart_unicode(request.META.get('HTTP_X_SOURCE_ACCOUNT'), strings_only=True) |
|
732 |
if not src_account: |
|
733 |
src_account = request.user |
|
731 | 734 |
if move_from: |
732 | 735 |
try: |
733 | 736 |
src_container, src_name = split_container_object_string(move_from) |
734 | 737 |
except ValueError: |
735 | 738 |
raise BadRequest('Invalid X-Move-From header') |
736 |
version_id = copy_or_move_object(request, v_account, src_container, src_name, v_container, v_object, move=True) |
|
739 |
version_id = copy_or_move_object(request, src_account, src_container, src_name, |
|
740 |
v_account, v_container, v_object, move=True) |
|
737 | 741 |
else: |
738 | 742 |
try: |
739 | 743 |
src_container, src_name = split_container_object_string(copy_from) |
740 | 744 |
except ValueError: |
741 | 745 |
raise BadRequest('Invalid X-Copy-From header') |
742 |
version_id = copy_or_move_object(request, v_account, src_container, src_name, v_container, v_object, move=False) |
|
746 |
version_id = copy_or_move_object(request, src_account, src_container, src_name, |
|
747 |
v_account, v_container, v_object, move=False) |
|
743 | 748 |
response = HttpResponse(status=201) |
744 | 749 |
response['X-Object-Version'] = version_id |
745 | 750 |
return response |
... | ... | |
875 | 880 |
# unauthorized (401), |
876 | 881 |
# badRequest (400) |
877 | 882 |
|
878 |
dest_path = request.META.get('HTTP_DESTINATION') |
|
883 |
dest_account = smart_unicode(request.META.get('HTTP_DESTINATION_ACCOUNT'), strings_only=True) |
|
884 |
if not dest_account: |
|
885 |
dest_account = request.user |
|
886 |
dest_path = smart_unicode(request.META.get('HTTP_DESTINATION'), strings_only=True) |
|
879 | 887 |
if not dest_path: |
880 | 888 |
raise BadRequest('Missing Destination header') |
881 | 889 |
try: |
... | ... | |
895 | 903 |
raise ItemNotFound('Container or object does not exist') |
896 | 904 |
validate_matching_preconditions(request, meta) |
897 | 905 |
|
898 |
version_id = copy_or_move_object(request, v_account, v_container, v_object, dest_container, dest_name, move=False) |
|
906 |
version_id = copy_or_move_object(request, v_account, v_container, v_object, |
|
907 |
dest_account, dest_container, dest_name, move=False) |
|
899 | 908 |
response = HttpResponse(status=201) |
900 | 909 |
response['X-Object-Version'] = version_id |
901 | 910 |
return response |
... | ... | |
908 | 917 |
# unauthorized (401), |
909 | 918 |
# badRequest (400) |
910 | 919 |
|
911 |
dest_path = request.META.get('HTTP_DESTINATION') |
|
920 |
dest_account = smart_unicode(request.META.get('HTTP_DESTINATION_ACCOUNT'), strings_only=True) |
|
921 |
if not dest_account: |
|
922 |
dest_account = request.user |
|
923 |
dest_path = smart_unicode(request.META.get('HTTP_DESTINATION'), strings_only=True) |
|
912 | 924 |
if not dest_path: |
913 | 925 |
raise BadRequest('Missing Destination header') |
914 | 926 |
try: |
... | ... | |
927 | 939 |
raise ItemNotFound('Container or object does not exist') |
928 | 940 |
validate_matching_preconditions(request, meta) |
929 | 941 |
|
930 |
version_id = copy_or_move_object(request, v_account, v_container, v_object, dest_container, dest_name, move=True) |
|
942 |
version_id = copy_or_move_object(request, v_account, v_container, v_object, |
|
943 |
dest_account, dest_container, dest_name, move=True) |
|
931 | 944 |
response = HttpResponse(status=201) |
932 | 945 |
response['X-Object-Version'] = version_id |
933 | 946 |
return response |
Also available in: Unified diff