[CalendarServer-changes] [8646] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Feb 10 08:18:46 PST 2012


Revision: 8646
          http://trac.macosforge.org/projects/calendarserver/changeset/8646
Author:   cdaboo at apple.com
Date:     2012-02-10 08:18:46 -0800 (Fri, 10 Feb 2012)
Log Message:
-----------
Support sync-level in sync REPORT.

Modified Paths:
--------------
    CalendarServer/trunk/twext/web2/dav/element/extensions.py
    CalendarServer/trunk/twistedcaldav/method/report_sync_collection.py

Modified: CalendarServer/trunk/twext/web2/dav/element/extensions.py
===================================================================
--- CalendarServer/trunk/twext/web2/dav/element/extensions.py	2012-02-10 16:17:15 UTC (rev 8645)
+++ CalendarServer/trunk/twext/web2/dav/element/extensions.py	2012-02-10 16:18:46 UTC (rev 8646)
@@ -2,7 +2,7 @@
 # See LICENSE for details.
 
 ##
-# Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
+# Copyright (c) 2005-2012 Apple Computer, Inc. All rights reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -34,6 +34,7 @@
     "AddMember",
     "SyncCollection",
     "SyncToken",
+    "SyncLevel",
 ]
 
 from twext.web2.dav.element.base import WebDAVElement, WebDAVTextElement
@@ -74,7 +75,7 @@
     """
     DAV report used to retrieve specific calendar component items via their
     URIs.
-    (CalDAV-access-09, section 9.9)
+    (draft-daboo-webdav-sync)
     """
     name = "sync-collection"
 
@@ -82,7 +83,8 @@
     # to relax the child restrictions
     allowed_children = {
         (dav_namespace, "sync-token"): (0, 1), # When used in the REPORT this is required
-        (dav_namespace, "prop"    ):   (0, 1),
+        (dav_namespace, "sync-level"): (0, 1), # When used in the REPORT this is required
+        (dav_namespace, "prop"      ): (0, 1),
     }
 
     def __init__(self, *children, **attributes):
@@ -90,17 +92,18 @@
 
         self.property = None
         self.sync_token = None
+        self.sync_level = None
 
         for child in self.children:
             qname = child.qname()
 
             if qname == (dav_namespace, "sync-token"):
-                
                 self.sync_token = str(child)
 
-            elif qname in (
-                (dav_namespace, "prop"    ),
-            ):
+            elif qname == (dav_namespace, "sync-level"):
+                self.sync_level = str(child)
+
+            elif qname == (dav_namespace, "prop"):
                 if self.property is not None:
                     raise ValueError("Only one of DAV:prop allowed")
                 self.property = child
@@ -112,3 +115,9 @@
     name = "sync-token"
     hidden = True
     protected = True
+
+class SyncLevel (WebDAVTextElement):
+    """
+    Synchronization level used in report.
+    """
+    name = "sync-level"

Modified: CalendarServer/trunk/twistedcaldav/method/report_sync_collection.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/report_sync_collection.py	2012-02-10 16:17:15 UTC (rev 8645)
+++ CalendarServer/trunk/twistedcaldav/method/report_sync_collection.py	2012-02-10 16:18:46 UTC (rev 8646)
@@ -1,5 +1,5 @@
 ##
-# Copyright (c) 2010 Apple Inc. All rights reserved.
+# Copyright (c) 2010-2012 Apple Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -59,10 +59,18 @@
    
     responses = []
 
-    depth = request.headers.getHeader("depth", None)
+    # Process Depth and sync-level for backwards compatibility
+    # Use sync-level if present and ignore Depth, else use Depth
+    if sync_collection.sync_level:
+        depth = sync_collection.sync_level
+        descriptor = "DAV:sync-level"
+    else:
+        depth = request.headers.getHeader("depth", None)
+        descriptor = "Depth header without DAV:sync-level"
+    
     if depth not in ("1", "infinity"):
         log.err("sync-collection report with invalid depth header: %s" % (depth,))
-        raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, "Invalid Depth header value"))
+        raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, "Invalid %s value" % (descriptor,)))
         
     propertyreq = sync_collection.property.children if sync_collection.property else None 
     
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120210/fb1591e2/attachment.html>


More information about the calendarserver-changes mailing list