[CalendarServer-changes] [11020] CalDAVTester/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Apr 9 18:42:06 PDT 2013


Revision: 11020
          http://trac.calendarserver.org//changeset/11020
Author:   cdaboo at apple.com
Date:     2013-04-09 18:42:06 -0700 (Tue, 09 Apr 2013)
Log Message:
-----------
Test that sync-token in PROPFIND Depth:1 on home changes for sharer and sharee when event changes in shared calendar.

Modified Paths:
--------------
    CalDAVTester/trunk/scripts/tests/CalDAV/caldavtest.dtd
    CalDAVTester/trunk/scripts/tests/CardDAV/caldavtest.dtd
    CalDAVTester/trunk/src/caldavtest.py
    CalDAVTester/trunk/src/request.py
    CalDAVTester/trunk/src/xmlDefs.py
    CalDAVTester/trunk/src/xmlUtils.py

Added Paths:
-----------
    CalDAVTester/trunk/Resource/CalDAV/sharing/sync/
    CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/
    CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/1.xml
    CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/2.xml
    CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/3.xml
    CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/4.ics
    CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/5.ics
    CalDAVTester/trunk/scripts/tests/CalDAV/sharing-sync.xml

Added: CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/1.xml
===================================================================
--- CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/1.xml	                        (rev 0)
+++ CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/1.xml	2013-04-10 01:42:06 UTC (rev 11020)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<CS:share xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/">
+    <CS:set>
+        <D:href>$cuaddr2:</D:href>
+        <CS:summary>My Shared Calendar</CS:summary>
+        <CS:read-write/>
+    </CS:set>
+</CS:share>

Added: CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/2.xml
===================================================================
--- CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/2.xml	                        (rev 0)
+++ CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/2.xml	2013-04-10 01:42:06 UTC (rev 11020)
@@ -0,0 +1,23 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<notification xmlns='http://calendarserver.org/ns/'>
+  <dtstamp></dtstamp>
+  <invite-notification shared-type='calendar'>
+    <uid></uid>
+    <href xmlns='DAV:'>$cuaddrurn2:</href>
+    <invite-noresponse/>
+    <access>
+      <read-write/>
+    </access>
+    <hosturl>
+      <href xmlns='DAV:'>$calendarhome1:/shared</href>
+    </hosturl>
+    <organizer>
+      <href xmlns='DAV:'>$principaluri1:</href>
+      <common-name>User 01</common-name>
+    </organizer>
+    <summary>My Shared Calendar</summary>
+    <supported-calendar-component-set xmlns='urn:ietf:params:xml:ns:caldav'>
+      <comp name="VEVENT" />
+    </supported-calendar-component-set>
+  </invite-notification>
+</notification>

Added: CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/3.xml
===================================================================
--- CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/3.xml	                        (rev 0)
+++ CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/3.xml	2013-04-10 01:42:06 UTC (rev 11020)
@@ -0,0 +1,13 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<invite-reply xmlns='http://calendarserver.org/ns/'>
+  <href xmlns='DAV:'>mailto:$email2:</href>
+  <invite-accepted/>
+  <hosturl>
+    <href xmlns='DAV:'>$calendarhome1:/shared</href>
+  </hosturl>
+  <in-reply-to>$inviteuid:</in-reply-to>
+  <summary>The Shared Calendar</summary>
+  <common-name>$username2:</common-name>
+  <first-name>$firstname2:</first-name>
+  <last-name>$lastname2:</last-name>
+</invite-reply>

Added: CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/4.ics
===================================================================
--- CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/4.ics	                        (rev 0)
+++ CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/4.ics	2013-04-10 01:42:06 UTC (rev 11020)
@@ -0,0 +1,29 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VTIMEZONE
+TZID:US/Eastern
+LAST-MODIFIED:20040110T032845Z
+BEGIN:STANDARD
+DTSTART:20001026T020000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
+TZNAME:EST
+TZOFFSETFROM:-0400
+TZOFFSETTO:-0500
+END:STANDARD
+BEGIN:DAYLIGHT
+DTSTART:20000404T020000
+RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
+TZNAME:EDT
+TZOFFSETFROM:-0500
+TZOFFSETTO:-0400
+END:DAYLIGHT
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:54E181BC7CCC373042B28842-2 at ninevah.local
+DTSTART;TZID=US/Eastern:$now.year.1:0101T100000
+DURATION:PT1H
+DTSTAMP:20051222T205953Z
+SUMMARY:event 1
+END:VEVENT
+END:VCALENDAR

Added: CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/5.ics
===================================================================
--- CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/5.ics	                        (rev 0)
+++ CalDAVTester/trunk/Resource/CalDAV/sharing/sync/depth1-cache/5.ics	2013-04-10 01:42:06 UTC (rev 11020)
@@ -0,0 +1,29 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VTIMEZONE
+TZID:US/Eastern
+LAST-MODIFIED:20040110T032845Z
+BEGIN:STANDARD
+DTSTART:20001026T020000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
+TZNAME:EST
+TZOFFSETFROM:-0400
+TZOFFSETTO:-0500
+END:STANDARD
+BEGIN:DAYLIGHT
+DTSTART:20000404T020000
+RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
+TZNAME:EDT
+TZOFFSETFROM:-0500
+TZOFFSETTO:-0400
+END:DAYLIGHT
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:54E181BC7CCC373042B28842-2 at ninevah.local
+DTSTART;TZID=US/Eastern:$now.year.1:0101T100000
+DURATION:PT4H
+DTSTAMP:20051222T205953Z
+SUMMARY:event 4
+END:VEVENT
+END:VCALENDAR

Modified: CalDAVTester/trunk/scripts/tests/CalDAV/caldavtest.dtd
===================================================================
--- CalDAVTester/trunk/scripts/tests/CalDAV/caldavtest.dtd	2013-04-09 17:12:46 UTC (rev 11019)
+++ CalDAVTester/trunk/scripts/tests/CalDAV/caldavtest.dtd	2013-04-10 01:42:06 UTC (rev 11020)
@@ -63,7 +63,7 @@
 			<!ELEMENT property (#PCDATA)>
 			<!ELEMENT variable (#PCDATA)>
 
-		<!ELEMENT grabelement (name, variable+)>
+		<!ELEMENT grabelement (name, parent*, variable+)>
 
 		<!ELEMENT grabcalproperty (name, variable)>
 		<!ELEMENT grabcalparameter (name, variable)>

Added: CalDAVTester/trunk/scripts/tests/CalDAV/sharing-sync.xml
===================================================================
--- CalDAVTester/trunk/scripts/tests/CalDAV/sharing-sync.xml	                        (rev 0)
+++ CalDAVTester/trunk/scripts/tests/CalDAV/sharing-sync.xml	2013-04-10 01:42:06 UTC (rev 11020)
@@ -0,0 +1,326 @@
+<?xml version="1.0" standalone="no"?>
+
+<!DOCTYPE caldavtest SYSTEM "caldavtest.dtd">
+
+<!--
+ Copyright (c) 2006-2013 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.
+ You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<caldavtest>
+	<description>Test calendar sharing and cached home sync tokens</description>
+
+	<require-feature>
+		<feature>caldav</feature>
+		<feature>shared-calendars</feature>
+		<feature>sync-report</feature>
+	</require-feature>
+
+	<start>
+		<request user="$userid1:" pswd="$pswd1:">
+			<method>DELETEALL</method>
+			<ruri>$notificationpath1:/</ruri>
+		</request>
+		<request user="$userid2:" pswd="$pswd2:">
+			<method>DELETEALL</method>
+			<ruri>$notificationpath2:/</ruri>
+		</request>
+		<request end-delete="yes">
+			<method>MKCALENDAR</method>
+			<ruri>$calendarhome1:/shared/</ruri>
+			<verify>
+				<callback>statusCode</callback>
+			</verify>
+		</request>
+		<request print-response='no'>
+			<method>PROPPATCH</method>
+			<ruri>$calendarhome1:/shared/</ruri>
+			<data>
+				<content-type>text/xml; charset=utf-8</content-type>
+				<filepath>Resource/Common/PROPPATCH/calendar-transp-opaque.xml</filepath>
+			</data>
+		</request>
+	</start>
+	
+	<test-suite name='Read-write calendar'>
+		<test name='1' ignore='no'>
+			<description>POST invitation</description>
+			<request print-response='no'>
+				<method>POST</method>
+				<ruri>$calendarhome1:/shared/</ruri>
+				<data>
+					<content-type>text/xml; charset=utf-8</content-type>
+					<filepath>Resource/CalDAV/sharing/sync/depth1-cache/1.xml</filepath>
+				</data>
+				<verify>
+					<callback>statusCode</callback>
+				</verify>
+			</request>
+		</test>
+		<test name='2'>
+			<description>Check Sharee notification collection</description>
+			<request user="$userid2:" pswd="$pswd2:" print-response='no'>
+				<method>WAITCOUNT 1</method>
+				<ruri>$notificationpath2:/</ruri>
+			</request>
+			<request user="$userid2:" pswd="$pswd2:" print-response='no'>
+				<method>GETNEW</method>
+				<ruri>$notificationpath2:/</ruri>
+				<verify>
+					<callback>xmlDataMatch</callback>
+					<arg>
+						<name>filepath</name>
+						<value>Resource/CalDAV/sharing/sync/depth1-cache/2.xml</value>
+					</arg>
+					<arg>
+						<name>filter</name>
+						<value>{http://calendarserver.org/ns/}dtstamp</value>
+						<value>{http://calendarserver.org/ns/}uid</value>
+					</arg>
+				</verify>
+				<grabelement>
+					<name>{http://calendarserver.org/ns/}invite-notification/{http://calendarserver.org/ns/}uid</name>
+					<variable>$inviteuid:</variable>
+				</grabelement>
+			</request>
+		</test>
+		<test name='3'>
+			<description>Sharee replies ACCEPTED</description>
+			<request user="$userid2:" pswd="$pswd2:" print-response='no'>
+				<method>POST</method>
+				<ruri>$calendarhome2:/</ruri>
+				<data substitutions='yes'>
+					<content-type>application/xml; charset=utf-8</content-type>
+					<filepath>Resource/CalDAV/sharing/sync/depth1-cache/3.xml</filepath>
+				</data>
+				<verify>
+					<callback>statusCode</callback>
+				</verify>
+				<grabelement>
+					<name>{DAV:}href</name>
+					<variable>$sharedcalendar:</variable>
+				</grabelement>
+			</request>
+		</test>
+		<test name='4'>
+			<description>Sharer Depth:1 PROPFIND</description>
+			<request print-response='no'>
+				<method>PROPFIND</method>
+				<ruri>$calendarhome1:/</ruri>
+				<header>
+					<name>Depth</name>
+					<value>1</value>
+				</header>
+				<data>
+					<content-type>text/xml; charset=utf-8</content-type>
+					<filepath>Resource/Common/PROPFIND/sync-token.xml</filepath>
+				</data>
+				<verify>
+					<callback>statusCode</callback>
+				</verify>
+				<grabelement>
+					<name>$verify-response-prefix:/{DAV:}sync-token</name>
+					<parent>$multistatus-response-prefix:[^{DAV:}href=$calendarhome1:/shared/]</parent>
+					<variable>$synctoken1_1:</variable>
+				</grabelement>
+			</request>
+		</test>
+		<test name='5'>
+			<description>Sharee Depth:1 PROPFIND</description>
+			<request user="$userid2:" pswd="$pswd2:" print-response='no'>
+				<method>PROPFIND</method>
+				<ruri>$calendarhome2:/</ruri>
+				<header>
+					<name>Depth</name>
+					<value>1</value>
+				</header>
+				<data>
+					<content-type>text/xml; charset=utf-8</content-type>
+					<filepath>Resource/Common/PROPFIND/sync-token.xml</filepath>
+				</data>
+				<verify>
+					<callback>statusCode</callback>
+				</verify>
+				<grabelement>
+					<name>$verify-response-prefix:/{DAV:}sync-token</name>
+					<parent>$multistatus-response-prefix:[^{DAV:}href=$sharedcalendar:/]</parent>
+					<variable>$synctoken2_1:</variable>
+				</grabelement>
+			</request>
+		</test>
+		<test name='6'>
+			<description>Sharee creates event</description>
+			<request user="$userid2:" pswd="$pswd2:" print-response='no'>
+				<method>PUT</method>
+				<ruri>$sharedcalendar:/1.ics</ruri>
+				<data>
+					<content-type>text/calendar; charset=utf-8</content-type>
+					<filepath>Resource/CalDAV/sharing/sync/depth1-cache/4.ics</filepath>
+				</data>
+				<verify>
+					<callback>statusCode</callback>
+				</verify>
+			</request>
+		</test>
+		<test name='7'>
+			<description>Sharer Depth:1 PROPFIND</description>
+			<request print-response='no'>
+				<method>PROPFIND</method>
+				<ruri>$calendarhome1:/</ruri>
+				<header>
+					<name>Depth</name>
+					<value>1</value>
+				</header>
+				<data>
+					<content-type>text/xml; charset=utf-8</content-type>
+					<filepath>Resource/Common/PROPFIND/sync-token.xml</filepath>
+				</data>
+				<verify>
+					<callback>xmlElementMatch</callback>
+					<arg>
+						<name>parent</name>
+						<value>$multistatus-response-prefix:[^{DAV:}href=$calendarhome1:/shared/]</value>
+					</arg>
+					<arg>
+						<name>exists</name>
+						<value>$verify-response-prefix:/{DAV:}sync-token[!$synctoken1_1:]</value>
+					</arg>
+				</verify>
+				<grabelement>
+					<name>$verify-response-prefix:/{DAV:}sync-token</name>
+					<parent>$multistatus-response-prefix:[^{DAV:}href=$calendarhome1:/shared/]</parent>
+					<variable>$synctoken1_2:</variable>
+				</grabelement>
+			</request>
+		</test>
+		<test name='8'>
+			<description>Sharee Depth:1 PROPFIND</description>
+			<request user="$userid2:" pswd="$pswd2:" print-response='no'>
+				<method>PROPFIND</method>
+				<ruri>$calendarhome2:/</ruri>
+				<header>
+					<name>Depth</name>
+					<value>1</value>
+				</header>
+				<data>
+					<content-type>text/xml; charset=utf-8</content-type>
+					<filepath>Resource/Common/PROPFIND/sync-token.xml</filepath>
+				</data>
+				<verify>
+					<callback>xmlElementMatch</callback>
+					<arg>
+						<name>parent</name>
+						<value>$multistatus-response-prefix:[^{DAV:}href=$sharedcalendar:/]</value>
+					</arg>
+					<arg>
+						<name>exists</name>
+						<value>$verify-response-prefix:/{DAV:}sync-token[!$synctoken2_1:]</value>
+					</arg>
+				</verify>
+				<grabelement>
+					<name>$verify-response-prefix:/{DAV:}sync-token</name>
+					<parent>$multistatus-response-prefix:[^{DAV:}href=$sharedcalendar:/]</parent>
+					<variable>$synctoken2_2:</variable>
+				</grabelement>
+			</request>
+		</test>
+		<test name='9'>
+			<description>Sharer changes event</description>
+			<request print-response='no'>
+				<method>PUT</method>
+				<ruri>$calendarhome1:/shared/1.ics</ruri>
+				<data>
+					<content-type>text/calendar; charset=utf-8</content-type>
+					<filepath>Resource/CalDAV/sharing/sync/depth1-cache/5.ics</filepath>
+				</data>
+				<verify>
+					<callback>statusCode</callback>
+				</verify>
+			</request>
+		</test>
+		<test name='10'>
+			<description>Sharer Depth:1 PROPFIND</description>
+			<request print-response='no'>
+				<method>PROPFIND</method>
+				<ruri>$calendarhome1:/</ruri>
+				<header>
+					<name>Depth</name>
+					<value>1</value>
+				</header>
+				<data>
+					<content-type>text/xml; charset=utf-8</content-type>
+					<filepath>Resource/Common/PROPFIND/sync-token.xml</filepath>
+				</data>
+				<verify>
+					<callback>xmlElementMatch</callback>
+					<arg>
+						<name>parent</name>
+						<value>$multistatus-response-prefix:[^{DAV:}href=$calendarhome1:/shared/]</value>
+					</arg>
+					<arg>
+						<name>exists</name>
+						<value>$verify-response-prefix:/{DAV:}sync-token[!$synctoken1_2:]</value>
+					</arg>
+				</verify>
+				<grabelement>
+					<name>$verify-response-prefix:/{DAV:}sync-token</name>
+					<parent>$multistatus-response-prefix:[^{DAV:}href=$calendarhome1:/shared/]</parent>
+					<variable>$synctoken1_3:</variable>
+				</grabelement>
+			</request>
+		</test>
+		<test name='11'>
+			<description>Sharee Depth:1 PROPFIND</description>
+			<request user="$userid2:" pswd="$pswd2:" print-response='no'>
+				<method>PROPFIND</method>
+				<ruri>$calendarhome2:/</ruri>
+				<header>
+					<name>Depth</name>
+					<value>1</value>
+				</header>
+				<data>
+					<content-type>text/xml; charset=utf-8</content-type>
+					<filepath>Resource/Common/PROPFIND/sync-token.xml</filepath>
+				</data>
+				<verify>
+					<callback>xmlElementMatch</callback>
+					<arg>
+						<name>parent</name>
+						<value>$multistatus-response-prefix:[^{DAV:}href=$sharedcalendar:/]</value>
+					</arg>
+					<arg>
+						<name>exists</name>
+						<value>$verify-response-prefix:/{DAV:}sync-token[!$synctoken2_2:]</value>
+					</arg>
+				</verify>
+				<grabelement>
+					<name>$verify-response-prefix:/{DAV:}sync-token</name>
+					<parent>$multistatus-response-prefix:[^{DAV:}href=$sharedcalendar:/]</parent>
+					<variable>$synctoken2_3:</variable>
+				</grabelement>
+			</request>
+		</test>
+	</test-suite>
+	
+	<end>
+		<request user="$useradmin:" pswd="$pswdadmin:">
+			<method>DELETEALL</method>
+			<ruri>$notificationpath1:/</ruri>
+			<ruri>$notificationpath2:/</ruri>
+			<ruri>$notificationpath3:/</ruri>
+			<ruri>$notificationpath4:/</ruri>
+		</request>
+	</end>
+	
+</caldavtest>

Modified: CalDAVTester/trunk/scripts/tests/CardDAV/caldavtest.dtd
===================================================================
--- CalDAVTester/trunk/scripts/tests/CardDAV/caldavtest.dtd	2013-04-09 17:12:46 UTC (rev 11019)
+++ CalDAVTester/trunk/scripts/tests/CardDAV/caldavtest.dtd	2013-04-10 01:42:06 UTC (rev 11020)
@@ -63,7 +63,7 @@
 			<!ELEMENT property (#PCDATA)>
 			<!ELEMENT variable (#PCDATA)>
 
-		<!ELEMENT grabelement (name, variable+)>
+		<!ELEMENT grabelement (name, parent*, variable+)>
 
 		<!ELEMENT grabcalproperty (name, variable)>
 		<!ELEMENT grabcalparameter (name, variable)>

Modified: CalDAVTester/trunk/src/caldavtest.py
===================================================================
--- CalDAVTester/trunk/src/caldavtest.py	2013-04-09 17:12:46 UTC (rev 11019)
+++ CalDAVTester/trunk/src/caldavtest.py	2013-04-10 01:42:06 UTC (rev 11020)
@@ -15,6 +15,7 @@
 ##
 import urllib
 import urlparse
+from src.xmlUtils import nodeForPath, xmlPathSplit
 
 """
 Class to encapsulate a single caldav test run.
@@ -632,9 +633,15 @@
                         self.manager.server_info.addextrasubs({variable: propvalue.encode("utf-8")})
 
         if req.grabelement:
-            for elementpath, variables in req.grabelement:
+            for item in req.grabelement:
+                if len(item) == 2:
+                    elementpath, variables = item
+                    parent = None
+                else:
+                    elementpath, parent, variables = item
+                    parent = self.manager.server_info.extrasubs(parent)
                 # grab the property here
-                elementvalues = self.extractElements(elementpath, respdata)
+                elementvalues = self.extractElements(elementpath, parent, respdata)
                 if elementvalues == None:
                     result = False
                     resulttxt += "\nElement %s was not extracted from response\n" % (elementpath,)
@@ -805,7 +812,7 @@
             return None
 
 
-    def extractElements(self, elementpath, respdata):
+    def extractElements(self, elementpath, parent, respdata):
 
         try:
             tree = ElementTree()
@@ -813,19 +820,38 @@
         except:
             return None
 
-        # Strip off the top-level item
-        if elementpath[0] == '/':
-            elementpath = elementpath[1:]
-            splits = elementpath.split('/', 1)
-            root = splits[0]
-            if tree.getroot().tag != root:
+        if parent:
+            tree_root = nodeForPath(tree.getroot(), parent)
+            if not tree_root:
                 return None
-            elif len(splits) == 1:
-                return tree.getroot().text
+            tree_root = tree_root[0]
+
+            # Handle absolute root element
+            if elementpath[0] == '/':
+                elementpath = elementpath[1:]
+            root_path, child_path = xmlPathSplit(elementpath)
+            if child_path:
+                if tree_root.tag != root_path:
+                    return None
+                e = tree_root.findall(child_path)
             else:
-                elementpath = splits[1]
+                e = (tree_root,)
 
-        e = tree.findall(elementpath)
+        else:
+            # Strip off the top-level item
+            if elementpath[0] == '/':
+                elementpath = elementpath[1:]
+                splits = elementpath.split('/', 1)
+                root = splits[0]
+                if tree.getroot().tag != root:
+                    return None
+                elif len(splits) == 1:
+                    return tree.getroot().text
+                else:
+                    elementpath = splits[1]
+
+            e = tree.findall(elementpath)
+
         if e is not None:
             return [item.text for item in e]
         else:

Modified: CalDAVTester/trunk/src/request.py
===================================================================
--- CalDAVTester/trunk/src/request.py	2013-04-09 17:12:46 UTC (rev 11019)
+++ CalDAVTester/trunk/src/request.py	2013-04-10 01:42:06 UTC (rev 11020)
@@ -411,17 +411,20 @@
     def parseMultiGrab(self, node, appendto):
 
         name = None
+        parent = None
         variable = None
         for child in node.getchildren():
             if child.tag in (src.xmlDefs.ELEMENT_NAME, src.xmlDefs.ELEMENT_PROPERTY):
                 name = self.manager.server_info.subs(child.text.encode("utf-8"))
+            elif child.tag == src.xmlDefs.ELEMENT_PARENT:
+                parent = self.manager.server_info.subs(child.text.encode("utf-8"))
             elif child.tag == src.xmlDefs.ELEMENT_VARIABLE:
                 if variable is None:
                     variable = []
                 variable.append(self.manager.server_info.subs(child.text.encode("utf-8")))
 
         if (name is not None) and (variable is not None):
-            appendto.append((name, variable))
+            appendto.append((name, variable,) if parent is None else (name, parent, variable,))
 
 
 

Modified: CalDAVTester/trunk/src/xmlDefs.py
===================================================================
--- CalDAVTester/trunk/src/xmlDefs.py	2013-04-09 17:12:46 UTC (rev 11019)
+++ CalDAVTester/trunk/src/xmlDefs.py	2013-04-10 01:42:06 UTC (rev 11020)
@@ -47,6 +47,7 @@
 ELEMENT_NAME = "name"
 ELEMENT_NONSSLPORT = "nonsslport"
 ELEMENT_NOTIFY = "notify"
+ELEMENT_PARENT = "parent"
 ELEMENT_PAUSE = "pause"
 ELEMENT_PERIOD = "period"
 ELEMENT_PROPERTY = "property"

Modified: CalDAVTester/trunk/src/xmlUtils.py
===================================================================
--- CalDAVTester/trunk/src/xmlUtils.py	2013-04-09 17:12:46 UTC (rev 11019)
+++ CalDAVTester/trunk/src/xmlUtils.py	2013-04-10 01:42:06 UTC (rev 11020)
@@ -50,3 +50,82 @@
         if child.tag == ename:
             return child.text.decode("utf-8")
     return ""
+
+
+
+def nodeForPath(root, path):
+    if '[' in path:
+        actual_path, tests = path.split('[', 1)
+    else:
+        actual_path = path
+        tests = None
+
+    # Handle absolute root element
+    if actual_path[0] == '/':
+        actual_path = actual_path[1:]
+    if '/' in actual_path:
+        root_path, child_path = actual_path.split('/', 1)
+        if root.tag != root_path:
+            return None
+        nodes = root.findall(child_path)
+    else:
+        root_path = actual_path
+        child_path = None
+        nodes = (root,)
+
+    if len(nodes) == 0:
+        return None
+
+    results = []
+
+    if tests:
+        tests = [item[:-1] for item in tests.split('[')]
+        for test in tests:
+            for node in nodes:
+                if test[0] == '@':
+                    if '=' in test:
+                        attr, value = test[1:].split('=')
+                        value = value[1:-1]
+                    else:
+                        attr = test[1:]
+                        value = None
+                    if attr in node.keys() and (value is None or node.get(attr) == value):
+                        results.append(node)
+                elif test[0] == '=':
+                    if node.text == test[1:]:
+                        results.append(node)
+                elif test[0] == '!':
+                    if node.text != test[1:]:
+                        results.append(node)
+                elif test[0] == '*':
+                    if node.text is not None and node.text.find(test[1:]) != -1:
+                        results.append(node)
+                elif test[0] == '+':
+                    if node.text is not None and node.text.startswith(test[1:]):
+                        results.append(node)
+                elif test[0] == '^':
+                    if "=" in test:
+                        element, value = test[1:].split("=", 1)
+                    else:
+                        element = test[1:]
+                        value = None
+                    for child in node.getchildren():
+                        if child.tag == element and (value is None or child.text == value):
+                            results.append(node)
+    else:
+        results = nodes
+
+    return results
+
+
+
+def xmlPathSplit(xpath):
+
+    pos = xpath.find("}")
+    if pos == -1:
+        return xpath, ""
+    pos = xpath[pos:].find("/") + pos
+    if pos == -1:
+        return xpath, ""
+    else:
+        return xpath[:pos], xpath[pos + 1:]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130409/82277584/attachment-0001.html>


More information about the calendarserver-changes mailing list