Container PUT can also be used for updating metadata/policy.
authorAntony Chazapis <chazapis@gmail.com>
Mon, 12 Sep 2011 10:08:51 +0000 (13:08 +0300)
committerAntony Chazapis <chazapis@gmail.com>
Mon, 12 Sep 2011 10:08:51 +0000 (13:08 +0300)
docs/source/devguide.rst
pithos/api/functions.py

index 1c10dbd..b99b645 100644 (file)
@@ -25,10 +25,11 @@ Document Revisions
 =========================  ================================
 Revision                   Description
 =========================  ================================
-0.6 (Sept 08, 2011)        Reply with Merkle hash as the ETag when updating objects.
+0.6 (Sept 12, 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.
 \                          Tags should be migrated to a meta value.
+\                          Container ``PUT`` updates metadata/policy.
 0.5 (July 22, 2011)        Object update from another object's data.
 \                          Support object truncate.
 \                          Create object using a standard HTML form.
@@ -448,7 +449,9 @@ Available policy directives:
 
 * ``versioning``: Set to ``auto``, ``manual`` or ``none`` (default is ``manual``)
 * ``quota``: Size limit in KB (default is ``0`` - unlimited)
+
+If the container already exists, the operation is equal to a ``POST`` with ``update`` defined.
+
 ================  ===============================
 Return Code       Description
 ================  ===============================
index 8ce83f0..89067e4 100644 (file)
@@ -332,9 +332,18 @@ def container_create(request, v_account, v_container):
     except NameError:
         ret = 202
     
-    if len(meta) > 0:
+    if ret == 202 and policy:
         try:
-            backend.update_container_meta(request.user, v_account, v_container, meta, replace=True)
+            backend.update_container_policy(request.user, v_account, v_container, policy, replace=False)
+        except NotAllowedError:
+            raise Unauthorized('Access denied')
+        except NameError:
+            raise ItemNotFound('Container does not exist')
+        except ValueError:
+            raise BadRequest('Invalid policy header')
+    if meta:
+        try:
+            backend.update_container_meta(request.user, v_account, v_container, meta, replace=False)
         except NotAllowedError:
             raise Unauthorized('Access denied')
         except NameError: