[CalendarServer-changes] [5757] CalDAVClientLibrary/trunk/src

source_changes at macosforge.org source_changes at macosforge.org
Wed Jun 16 16:14:00 PDT 2010


Revision: 5757
          http://trac.macosforge.org/projects/calendarserver/changeset/5757
Author:   cdaboo at apple.com
Date:     2010-06-16 16:14:00 -0700 (Wed, 16 Jun 2010)
Log Message:
-----------
Be smarter about printing properties by actually looking at what they are. Also add a -l option
to props to allow printing the actual (complex) XML elements.

Modified Paths:
--------------
    CalDAVClientLibrary/trunk/src/browser/commands/props.py
    CalDAVClientLibrary/trunk/src/client/clientsession.py
    CalDAVClientLibrary/trunk/src/protocol/caldav/__init__.py
    CalDAVClientLibrary/trunk/src/protocol/webdav/__init__.py
    CalDAVClientLibrary/trunk/src/protocol/webdav/propfindparser.py

Modified: CalDAVClientLibrary/trunk/src/browser/commands/props.py
===================================================================
--- CalDAVClientLibrary/trunk/src/browser/commands/props.py	2010-06-16 22:32:57 UTC (rev 5756)
+++ CalDAVClientLibrary/trunk/src/browser/commands/props.py	2010-06-16 23:14:00 UTC (rev 5757)
@@ -32,14 +32,17 @@
         
         names = False
         all = False
+        xmllist = False
         path = None
 
-        opts, args = getopt.getopt(shlex.split(options), 'an')
+        opts, args = getopt.getopt(shlex.split(options), 'aln')
 
         for name, _ignore_value in opts:
             
             if name == "-a":
                 all = True
+            elif name == "-l":
+                xmllist = True
             elif name == "-n":
                 names = True
             else:
@@ -69,7 +72,7 @@
                 props = None
             else:
                 props = self.shell.account.session.getPropertyNames(resource)
-            results, bad = self.shell.account.session.getProperties(resource, props)
+            results, bad = self.shell.account.session.getProperties(resource, props, xmllist)
             print "OK Properties:"
             utils.printProperties(results)
             if bad:
@@ -88,7 +91,8 @@
 Options:
 -n    list property names only
 -a    list all properties via allprop
-    if neither of the above are set then property names are first listed, and then values of those looked up.
+-l    list actual property XML values
+    if neither -n nor -a are set then property names are first listed, and then values of those looked up.
     only one of -n and -a can be set.
 """ % (name,)
 

Modified: CalDAVClientLibrary/trunk/src/client/clientsession.py
===================================================================
--- CalDAVClientLibrary/trunk/src/client/clientsession.py	2010-06-16 22:32:57 UTC (rev 5756)
+++ CalDAVClientLibrary/trunk/src/client/clientsession.py	2010-06-16 23:14:00 UTC (rev 5757)
@@ -40,7 +40,7 @@
 from protocol.webdav.proppatch import PropPatch
 from protocol.webdav.put import Put
 from protocol.webdav.session import Session
-from xml.etree.ElementTree import Element
+from xml.etree.ElementTree import Element, tostring
 import types
 
 class CalDAVSession(Session):
@@ -142,7 +142,7 @@
     
         return results
 
-    def getProperties(self, rurl, props):
+    def getProperties(self, rurl, props, xmldata=False):
 
         assert(isinstance(rurl, URL))
 
@@ -181,7 +181,7 @@
                             results[name] = value
                     for name, value in item.getNodeProperties().iteritems():
                         if name not in results:
-                            results[name] = value
+                            results[name] = tostring(value) if xmldata else value
                     bad = item.getBadProperties()
         else:
             self.handleHTTPError(request)

Modified: CalDAVClientLibrary/trunk/src/protocol/caldav/__init__.py
===================================================================
--- CalDAVClientLibrary/trunk/src/protocol/caldav/__init__.py	2010-06-16 22:32:57 UTC (rev 5756)
+++ CalDAVClientLibrary/trunk/src/protocol/caldav/__init__.py	2010-06-16 23:14:00 UTC (rev 5757)
@@ -1,5 +1,5 @@
 ##
-# Copyright (c) 2007-2009 Apple Inc. All rights reserved.
+# Copyright (c) 2007-2010 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.
@@ -13,18 +13,3 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 ##
-
-from protocol.webdav.propfindparser import PropFindParser
-from protocol.webdav.definitions import davxml
-from protocol.caldav.definitions import caldavxml, csxml
-
-PropFindParser.textProperties.add(caldavxml.calendar_description)
-PropFindParser.textProperties.add(caldavxml.calendar_timezone)
-
-PropFindParser.hrefListProperties.add(caldavxml.calendar_home_set)
-PropFindParser.hrefListProperties.add(caldavxml.calendar_user_address_set)
-PropFindParser.hrefListProperties.add(caldavxml.calendar_free_busy_set)
-PropFindParser.hrefProperties.add(caldavxml.schedule_outbox_URL)
-PropFindParser.hrefProperties.add(caldavxml.schedule_inbox_URL)
-PropFindParser.hrefProperties.add(csxml.calendar_proxy_read_for)
-PropFindParser.hrefProperties.add(csxml.calendar_proxy_write_for)

Modified: CalDAVClientLibrary/trunk/src/protocol/webdav/__init__.py
===================================================================
--- CalDAVClientLibrary/trunk/src/protocol/webdav/__init__.py	2010-06-16 22:32:57 UTC (rev 5756)
+++ CalDAVClientLibrary/trunk/src/protocol/webdav/__init__.py	2010-06-16 23:14:00 UTC (rev 5757)
@@ -1,5 +1,5 @@
 ##
-# Copyright (c) 2007-2009 Apple Inc. All rights reserved.
+# Copyright (c) 2007-2010 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.
@@ -13,27 +13,3 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 ##
-
-from protocol.webdav.propfindparser import PropFindParser
-from protocol.webdav.definitions import davxml, csxml
-
-PropFindParser.textProperties.add(davxml.creationdate)
-PropFindParser.textProperties.add(davxml.displayname)
-PropFindParser.textProperties.add(davxml.getcontentlanguage)
-PropFindParser.textProperties.add(davxml.getcontentlength)
-PropFindParser.textProperties.add(davxml.getcontenttype)
-PropFindParser.textProperties.add(davxml.getetag)
-PropFindParser.textProperties.add(davxml.getlastmodified)
-PropFindParser.textProperties.add(davxml.quota_available_bytes)
-PropFindParser.textProperties.add(davxml.quota_used_bytes)
-
-PropFindParser.hrefProperties.add(davxml.current_user_principal)
-PropFindParser.hrefProperties.add(davxml.owner)
-PropFindParser.hrefProperties.add(davxml.principal_URL)
-
-PropFindParser.hrefListProperties.add(davxml.principal_collection_set)
-PropFindParser.hrefListProperties.add(davxml.alternate_URI_set)
-PropFindParser.hrefListProperties.add(davxml.group_member_set)
-PropFindParser.hrefListProperties.add(davxml.group_membership)
-PropFindParser.hrefListProperties.add(csxml.expanded_group_member_set)
-PropFindParser.hrefListProperties.add(csxml.expanded_group_membership)

Modified: CalDAVClientLibrary/trunk/src/protocol/webdav/propfindparser.py
===================================================================
--- CalDAVClientLibrary/trunk/src/protocol/webdav/propfindparser.py	2010-06-16 22:32:57 UTC (rev 5756)
+++ CalDAVClientLibrary/trunk/src/protocol/webdav/propfindparser.py	2010-06-16 23:14:00 UTC (rev 5757)
@@ -1,5 +1,5 @@
 ##
-# Copyright (c) 2007-2008 Apple Inc. All rights reserved.
+# Copyright (c) 2007-2010 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.
@@ -114,17 +114,29 @@
         if badstatus:
             result.addBadProperty(QName(prop.tag), badstatus)
 
-        elif prop.tag in PropFindParser.textProperties:
-            self.parsePropElementText(prop, result)
-
-        elif prop.tag in PropFindParser.hrefProperties:
-            self.parsePropElementHref(prop, result, False)
-
-        elif prop.tag in PropFindParser.hrefListProperties:
-            self.parsePropElementHref(prop, result, True)
-
+        # Determine what type of content we have
         else:
-            self.parsePropElementUnknown(prop, result)
+            children = prop.getchildren()
+            children_length = len(children)
+            if children_length == 0:
+                self.parsePropElementText(prop, result)
+            elif prop.text is None or not prop.text.strip():
+                if children_length == 1:
+                    if children[0].tag == davxml.href:
+                        self.parsePropElementHref(prop, result, False)
+                    else:
+                        self.parsePropElementUnknown(prop, result)
+                else:
+                    allHref = True
+                    for child in children:
+                        if child.tag != davxml.href:
+                            allHref = False
+                    if allHref:
+                        self.parsePropElementHref(prop, result, True)
+                    else:
+                        self.parsePropElementUnknown(prop, result)
+            else:
+                self.parsePropElementUnknown(prop, result)
 
     def parsePropElementText(self, prop, result):
         # Grab the element data
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100616/270df135/attachment-0001.html>


More information about the calendarserver-changes mailing list