[CalendarServer-changes] [5801] CalendarServer/branches/new-store

source_changes at macosforge.org source_changes at macosforge.org
Tue Jun 22 14:43:47 PDT 2010


Revision: 5801
          http://trac.macosforge.org/projects/calendarserver/changeset/5801
Author:   cdaboo at apple.com
Date:     2010-06-22 14:43:42 -0700 (Tue, 22 Jun 2010)
Log Message:
-----------
propertystore always raises KeyError for removal of non-existent property. PROPPATCH handler now
ignores those as required by WebDAV.

Modified Paths:
--------------
    CalendarServer/branches/new-store/twext/web2/dav/method/proppatch.py
    CalendarServer/branches/new-store/txdav/propertystore/none.py
    CalendarServer/branches/new-store/txdav/propertystore/test/base.py
    CalendarServer/branches/new-store/txdav/propertystore/xattr.py

Modified: CalendarServer/branches/new-store/twext/web2/dav/method/proppatch.py
===================================================================
--- CalendarServer/branches/new-store/twext/web2/dav/method/proppatch.py	2010-06-22 21:32:58 UTC (rev 5800)
+++ CalendarServer/branches/new-store/twext/web2/dav/method/proppatch.py	2010-06-22 21:43:42 UTC (rev 5801)
@@ -97,7 +97,7 @@
 
             properties = container.children
 
-            def do(action, property):
+            def do(action, property, removing=False):
                 """
                 Perform action(property, request) while maintaining an
                 undo queue.
@@ -122,13 +122,19 @@
                     yield x
                     x.getResult()
                 except KeyError, e:
-                    # Convert KeyError exception into HTTPError
-                    responses.add(
-                        Failure(exc_value=HTTPError(StatusResponse(responsecode.FORBIDDEN, str(e)))),
-                        property
-                    )
-                    yield False
-                    return
+                    # Removing a non-existent property is OK according to WebDAV
+                    if removing:
+                        responses.add(responsecode.OK, property)
+                        yield True
+                        return
+                    else:
+                        # Convert KeyError exception into HTTPError
+                        responses.add(
+                            Failure(exc_value=HTTPError(StatusResponse(responsecode.FORBIDDEN, str(e)))),
+                            property
+                        )
+                        yield False
+                        return
                 except:
                     responses.add(Failure(), property)
                     yield False
@@ -153,7 +159,7 @@
                         gotError = True
             elif isinstance(setOrRemove, davxml.Remove):
                 for property in properties:
-                    ok = waitForDeferred(do(self.removeProperty, property))
+                    ok = waitForDeferred(do(self.removeProperty, property, True))
                     yield ok
                     ok = ok.getResult()
                     if not ok:

Modified: CalendarServer/branches/new-store/txdav/propertystore/none.py
===================================================================
--- CalendarServer/branches/new-store/txdav/propertystore/none.py	2010-06-22 21:32:58 UTC (rev 5800)
+++ CalendarServer/branches/new-store/txdav/propertystore/none.py	2010-06-22 21:43:42 UTC (rev 5801)
@@ -47,6 +47,8 @@
 
         if key in self.modified:
             del self.modified[key]
+        else:
+            raise KeyError(key)
 
     def __getitem__(self, key):
         validKey(key)

Modified: CalendarServer/branches/new-store/txdav/propertystore/test/base.py
===================================================================
--- CalendarServer/branches/new-store/txdav/propertystore/test/base.py	2010-06-22 21:32:58 UTC (rev 5800)
+++ CalendarServer/branches/new-store/txdav/propertystore/test/base.py	2010-06-22 21:43:42 UTC (rev 5801)
@@ -82,7 +82,7 @@
         def doDelete():
             del self.propertyStore[propertyName("xyzzy")]
 
-        doDelete()
+        self.assertRaises(KeyError, doDelete)
 
     def test_keyInPropertyName(self):
         store = self.propertyStore

Modified: CalendarServer/branches/new-store/txdav/propertystore/xattr.py
===================================================================
--- CalendarServer/branches/new-store/txdav/propertystore/xattr.py	2010-06-22 21:32:58 UTC (rev 5800)
+++ CalendarServer/branches/new-store/txdav/propertystore/xattr.py	2010-06-22 21:43:42 UTC (rev 5801)
@@ -107,13 +107,12 @@
     #
 
     def __delitem__(self, key):
-        """
-        We do not fail if the key does not current exist as per WebDAV PROPPATCH note above.
-        """
         validKey(key)
 
         if key in self.modified:
             del self.modified[key]
+        elif self._encodeKey(key) not in self.attrs:
+            raise KeyError(key)
 
         self.removed.add(key)
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100622/93da6817/attachment.html>


More information about the calendarserver-changes mailing list