[CalendarServer-changes] [4473] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Fri Jul 24 10:10:49 PDT 2009


Revision: 4473
          http://trac.macosforge.org/projects/calendarserver/changeset/4473
Author:   cdaboo at apple.com
Date:     2009-07-24 10:10:49 -0700 (Fri, 24 Jul 2009)
Log Message:
-----------
Handle the case of a non-existent directory record when converting fb-set properties.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/test/test_upgrade.py
    CalendarServer/trunk/twistedcaldav/upgrade.py

Modified: CalendarServer/trunk/twistedcaldav/test/test_upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_upgrade.py	2009-07-23 19:59:15 UTC (rev 4472)
+++ CalendarServer/trunk/twistedcaldav/test/test_upgrade.py	2009-07-24 17:10:49 UTC (rev 4473)
@@ -214,11 +214,14 @@
 
 
         #
-        # Shortname not in directory, raise an UpgradeError
+        # Shortname not in directory, return empty string
         #
 
+        expected = "<?xml version='1.0' encoding='UTF-8'?><calendar-free-busy-set xmlns='urn:ietf:params:xml:ns:caldav'/>"
         value = "<?xml version='1.0' encoding='UTF-8'?>\r\n<calendar-free-busy-set xmlns='urn:ietf:params:xml:ns:caldav'>\r\n  <href xmlns='DAV:'>/calendars/users/nonexistent/calendar</href>\r\n</calendar-free-busy-set>\r\n"
-        self.assertRaises(UpgradeError, updateFreeBusySet, value, directory)
+        newValue = updateFreeBusySet(value, directory)
+        newValue = zlib.decompress(newValue)
+        self.assertEquals(newValue, expected)
 
 
     def test_calendarsUpgradeWithTypes(self):

Modified: CalendarServer/trunk/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/upgrade.py	2009-07-23 19:59:15 UTC (rev 4472)
+++ CalendarServer/trunk/twistedcaldav/upgrade.py	2009-07-24 17:10:49 UTC (rev 4473)
@@ -486,8 +486,9 @@
     shortName = pieces[3]
     record = directory.recordWithShortName(recordType, shortName)
     if record is None:
-        msg = "Can't update free-busy href; %s is not in the directory" % shortName
-        raise UpgradeError(msg)
+        # We will simply ignore this and not write out an fb-set entry
+        log.error("Can't update free-busy href; %s is not in the directory" % shortName)
+        return ""
 
     uid = record.uid
     newHref = "/calendars/__uids__/%s/%s/" % (uid, pieces[4])
@@ -522,7 +523,8 @@
             fbset.add(href)
         else:
             didUpdate = True
-            fbset.add(newHref)
+            if newHref != "":
+                fbset.add(newHref)
 
     if didUpdate:
         property = caldavxml.CalendarFreeBusySet(*[davxml.HRef(href)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090724/16913660/attachment.html>


More information about the calendarserver-changes mailing list