[CalendarServer-changes] [8618] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Jan 31 16:56:18 PST 2012


Revision: 8618
          http://trac.macosforge.org/projects/calendarserver/changeset/8618
Author:   cdaboo at apple.com
Date:     2012-01-31 16:56:17 -0800 (Tue, 31 Jan 2012)
Log Message:
-----------
Support the Brief header.

Modified Paths:
--------------
    CalendarServer/trunk/twext/web2/dav/method/propfind.py
    CalendarServer/trunk/twext/web2/http_headers.py
    CalendarServer/trunk/twistedcaldav/method/propfind.py
    CalendarServer/trunk/twistedcaldav/method/report_common.py

Modified: CalendarServer/trunk/twext/web2/dav/method/propfind.py
===================================================================
--- CalendarServer/trunk/twext/web2/dav/method/propfind.py	2012-02-01 00:51:58 UTC (rev 8617)
+++ CalendarServer/trunk/twext/web2/dav/method/propfind.py	2012-02-01 00:56:17 UTC (rev 8618)
@@ -1,6 +1,6 @@
 # -*- test-case-name: twext.web2.dav.test.test_prop.PROP.test_PROPFIND -*-
 ##
-# Copyright (c) 2005-2011 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
@@ -112,6 +112,8 @@
     if depth == "infinity":
         raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, davxml.PropfindFiniteDepth()))
 
+    brief = request.headers.getHeader("brief", False)
+
     xml_responses = []
 
     # FIXME: take advantage of the new generative properties of findChildren
@@ -170,19 +172,17 @@
                         resource_property = resource_property.getResult()
                     except:
                         f = Failure()
-
-                        log.err("Error reading property %r for resource %s: %s" % (property, uri, f.value))
-
                         status = statusForFailure(f, "getting property: %s" % (property,))
                         if status not in properties_by_status:
                             properties_by_status[status] = []
-                        properties_by_status[status].append(propertyName(property))
+                        if not brief or status != responsecode.NOT_FOUND:
+                            properties_by_status[status].append(propertyName(property))
                     else:
                         if resource_property is not None:
                             properties_by_status[responsecode.OK].append(resource_property)
-                        else:
+                        elif not brief:
                             properties_by_status[responsecode.NOT_FOUND].append(propertyName(property))
-                else:
+                elif not brief:
                     properties_by_status[responsecode.NOT_FOUND].append(propertyName(property))
 
         propstats = []

Modified: CalendarServer/trunk/twext/web2/http_headers.py
===================================================================
--- CalendarServer/trunk/twext/web2/http_headers.py	2012-02-01 00:51:58 UTC (rev 8617)
+++ CalendarServer/trunk/twext/web2/http_headers.py	2012-02-01 00:56:17 UTC (rev 8618)
@@ -1,7 +1,7 @@
 # -*- test-case-name: twext.web2.test.test_http_headers -*-
 ##
 # Copyright (c) 2008 Twisted Matrix Laboratories.
-# Copyright (c) 2010 Apple Computer, Inc. All rights reserved.
+# Copyright (c) 2010-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
@@ -1256,6 +1256,18 @@
     else:
         return "F"
 
+def parseBrief(brief):
+    # We accept upper or lower case
+    if brief.upper() == "F":
+        return False
+    elif brief.upper() == "T":
+        return True
+    raise ValueError("Invalid brief header value: %s" % (brief,))
+
+def generateBrief(brief):
+    # MS definition uses lower case
+    return "t" if brief else "f"
+
 ##### Random stuff that looks useful.
 # def sortMimeQuality(s):
 #     def sorter(item1, item2):
@@ -1575,6 +1587,7 @@
     }
 
 parser_dav_headers = {
+    'Brief'       : (last, parseBrief),
     'DAV'         : (tokenize, list),
     'Depth'       : (last, parseDepth),
     'Destination' : (last,), # TODO: URI object?
@@ -1586,6 +1599,7 @@
 }
 
 generator_dav_headers = {
+    'Brief'       : (),
     'DAV'         : (generateList, singleHeader),
     'Depth'       : (singleHeader),
     'Destination' : (singleHeader),

Modified: CalendarServer/trunk/twistedcaldav/method/propfind.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/propfind.py	2012-02-01 00:51:58 UTC (rev 8617)
+++ CalendarServer/trunk/twistedcaldav/method/propfind.py	2012-02-01 00:56:17 UTC (rev 8618)
@@ -1,6 +1,6 @@
 # -*- test-case-name: twext.web2.dav.test.test_prop.PROP.test_PROPFIND -*-
 ##
-# Copyright (c) 2005-2011 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
@@ -108,6 +108,8 @@
     if depth == "infinity":
         raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, davxml.PropfindFiniteDepth()))
 
+    brief = request.headers.getHeader("brief", False)
+
     xml_responses = []
 
     # FIXME: take advantage of the new generative properties of findChildren
@@ -166,17 +168,17 @@
                             resource_property = (yield resource.readProperty(property, request))
                         except:
                             f = Failure()
-    
                             status = statusForFailure(f, "getting property: %s" % (property,))
                             if status not in properties_by_status:
                                 properties_by_status[status] = []
-                            properties_by_status[status].append(propertyName(property))
+                            if not brief or status != responsecode.NOT_FOUND:
+                                properties_by_status[status].append(propertyName(property))
                         else:
                             if resource_property is not None:
                                 properties_by_status[responsecode.OK].append(resource_property)
-                            else:
+                            elif not brief:
                                 properties_by_status[responsecode.NOT_FOUND].append(propertyName(property))
-                    else:
+                    elif not brief:
                         properties_by_status[responsecode.NOT_FOUND].append(propertyName(property))
 
             propstats = []

Modified: CalendarServer/trunk/twistedcaldav/method/report_common.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/report_common.py	2012-02-01 00:51:58 UTC (rev 8617)
+++ CalendarServer/trunk/twistedcaldav/method/report_common.py	2012-02-01 00:56:17 UTC (rev 8618)
@@ -1,5 +1,5 @@
 ##
-# Copyright (c) 2006-2011 Apple Inc. All rights reserved.
+# Copyright (c) 2006-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.
@@ -333,6 +333,8 @@
         responsecode.NOT_FOUND : [],
     }
     
+    brief = request.headers.getHeader("brief", False)
+
     for property in props:
         if isinstance(property, caldavxml.CalendarData):
             # Handle private events access restrictions
@@ -364,17 +366,15 @@
                 prop = (yield resource.readProperty(qname, request))
                 if prop is not None:
                     properties_by_status[responsecode.OK].append(prop)
-                else:
+                elif not brief:
                     properties_by_status[responsecode.NOT_FOUND].append(propertyName(qname))
             except HTTPError:
                 f = Failure()
-    
                 status = statusForFailure(f, "getting property: %s" % (qname,))
-                if status != responsecode.NOT_FOUND:
-                    log.err("Error reading property %r for resource %s: %s" % (qname, request.uri, f.value))
                 if status not in properties_by_status: properties_by_status[status] = []
-                properties_by_status[status].append(propertyName(qname))
-        else:
+                if not brief or status != responsecode.NOT_FOUND:
+                    properties_by_status[status].append(propertyName(qname))
+        elif not brief:
             properties_by_status[responsecode.NOT_FOUND].append(propertyName(qname))
     
     returnValue(properties_by_status)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120131/f94e7ed7/attachment.html>


More information about the calendarserver-changes mailing list