[CalendarServer-changes] [2834] CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/ resource.py

source_changes at macosforge.org source_changes at macosforge.org
Tue Aug 19 12:08:44 PDT 2008


Revision: 2834
          http://trac.macosforge.org/projects/calendarserver/changeset/2834
Author:   cdaboo at apple.com
Date:     2008-08-19 12:08:44 -0700 (Tue, 19 Aug 2008)
Log Message:
-----------
Handle case where default scheduling calendar is deleted or moved.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/resource.py

Modified: CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/resource.py	2008-08-19 19:07:56 UTC (rev 2833)
+++ CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/resource.py	2008-08-19 19:08:44 UTC (rev 2834)
@@ -39,7 +39,8 @@
 from twisted.web2.dav.davxml import dav_namespace
 from twisted.web2.dav.http import ErrorResponse
 from twisted.web2.dav.resource import TwistedACLInheritable
-from twisted.web2.dav.util import joinURL, parentForURL, unimplemented
+from twisted.web2.dav.util import joinURL, parentForURL, unimplemented,\
+    normalizeURL
 from twisted.web2.http import HTTPError, RedirectResponse, StatusResponse, Response
 from twisted.web2.http_headers import MimeType
 from twisted.web2.iweb import IResponse
@@ -59,6 +60,8 @@
 from twistedcaldav.ical import Component as iComponent
 from twistedcaldav.log import LoggingMixIn
 
+from urlparse import urlsplit
+
 if twistedcaldav.__version__:
     serverVersion = twisted.web2.server.VERSION + " TwistedCalDAV/" + twistedcaldav.__version__
 else:
@@ -485,11 +488,18 @@
         if inboxURL:
             inbox = (yield request.locateResource(inboxURL))
             inbox.processFreeBusyCalendar(request.path, False)
+            
+            # Also check the default calendar setting and remove it if the default is deleted
+            default = (yield inbox.readProperty((caldav_namespace, "schedule-default-calendar-URL"), request))
+            if len(default.children) == 1:
+                defaultURL = normalizeURL(str(default.children[0]))
+                if normalizeURL(request.path) == defaultURL:
+                    yield inbox.writeProperty(caldavxml.ScheduleDefaultCalendarURL())               
 
     @inlineCallbacks
     def movedCalendar(self, request, destination, destination_uri):
         """
-        Calendar has been deleted. Need to do some extra clean-up.
+        Calendar has been moved. Need to do some extra clean-up.
 
         @param request:
         @type request:
@@ -499,9 +509,18 @@
         principal = (yield self.ownerPrincipal(request))
         inboxURL = principal.scheduleInboxURL()
         if inboxURL:
+            (_ignore_scheme, _ignore_host, destination_path, _ignore_query, _ignore_fragment) = urlsplit(normalizeURL(destination_uri))
+
             inbox = (yield request.locateResource(inboxURL))
             inbox.processFreeBusyCalendar(request.path, False)
             inbox.processFreeBusyCalendar(destination_uri, destination.isCalendarOpaque())
+            
+            # Also check the default calendar setting and remove it if the default is deleted
+            default = (yield inbox.readProperty((caldav_namespace, "schedule-default-calendar-URL"), request))
+            if len(default.children) == 1:
+                defaultURL = normalizeURL(str(default.children[0]))
+                if normalizeURL(request.path) == defaultURL:
+                    yield inbox.writeProperty(caldavxml.ScheduleDefaultCalendarURL(davxml.HRef(destination_path)))               
 
     def isCalendarOpaque(self):
         
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080819/a83746bf/attachment.html 


More information about the calendarserver-changes mailing list