Allow cross-account object from object update.
authorAntony Chazapis <chazapis@gmail.com>
Fri, 30 Sep 2011 09:44:25 +0000 (12:44 +0300)
committerAntony Chazapis <chazapis@gmail.com>
Fri, 30 Sep 2011 09:44:25 +0000 (12:44 +0300)
Fixes #1379

docs/source/devguide.rst
pithos/api/functions.py

index 9604aa8..94fd5fb 100644 (file)
@@ -25,10 +25,11 @@ Document Revisions
 =========================  ================================
 Revision                   Description
 =========================  ================================
-0.7 (Sept 29, 2011)        Suggest upload/download methods using hashmaps.
+0.7 (Sept 30, 2011)        Suggest upload/download methods using hashmaps.
 \                          Propose syncing algorithm.
 \                          Support cross-account object copy and move.
 \                          Pass token as a request parameter when using ``POST`` via an HTML form.
+\                          Optionally use source account to update object from another object.
 0.6 (Sept 13, 2011)        Reply with Merkle hash as the ETag when updating objects.
 \                          Include version id in object replace/change replies.
 \                          Change conflict (409) replies format to text.
@@ -826,6 +827,7 @@ Transfer-Encoding     Set to ``chunked`` to specify incremental uploading (if us
 Content-Encoding      The encoding of the object (optional)
 Content-Disposition   The presentation style of the object (optional)
 X-Source-Object       Update with data from the object at path ``/<container>/<object>`` (optional, to update)
+X-Source-Account      The source account to update from
 X-Source-Version      The source version to update from (optional, to update)
 X-Object-Bytes        The updated object's final size (optional, when updating)
 X-Object-Manifest     Object parts prefix in ``<container>/<object>`` form (optional)
index 5bb83b4..84a6609 100644 (file)
@@ -1058,13 +1058,16 @@ def object_update(request, v_account, v_container, v_object):
     elif offset > size:
         raise RangeNotSatisfiable('Supplied offset is beyond object limits')
     if src_object:
+        src_account = smart_unicode(request.META.get('HTTP_X_SOURCE_ACCOUNT'), strings_only=True)
+        if not src_account:
+            src_account = request.user
         src_container, src_name = split_container_object_string(src_object)
         src_container = smart_unicode(src_container, strings_only=True)
         src_name = smart_unicode(src_name, strings_only=True)
         src_version = request.META.get('HTTP_X_SOURCE_VERSION')
         try:
-            src_size, src_hashmap = request.backend.get_object_hashmap(
-                request.user, v_account, src_container, src_name, src_version)
+            src_size, src_hashmap = request.backend.get_object_hashmap(request.user,
+                                        src_account, src_container, src_name, src_version)
         except NotAllowedError:
             raise Unauthorized('Access denied')
         except NameError: