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

source_changes at macosforge.org source_changes at macosforge.org
Fri Aug 29 13:55:11 PDT 2008


Revision: 2916
          http://trac.macosforge.org/projects/calendarserver/changeset/2916
Author:   sagen at apple.com
Date:     2008-08-29 13:55:10 -0700 (Fri, 29 Aug 2008)
Log Message:
-----------
Don't send notifications when a calendar home is being provisioned

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/cache.py
    CalendarServer/trunk/twistedcaldav/directory/calendar.py

Modified: CalendarServer/trunk/twistedcaldav/cache.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/cache.py	2008-08-29 20:08:40 UTC (rev 2915)
+++ CalendarServer/trunk/twistedcaldav/cache.py	2008-08-29 20:55:10 UTC (rev 2916)
@@ -76,12 +76,21 @@
     def __init__(self, resource, cachePool=None):
         self._resource = resource
         self._cachePool = cachePool
+        self._notify = True
 
+    def enableNotify(self, arg):
+        url = self._resource.url()
+        self.log_debug("enableNotify: %s" % (url,))
+        self._notify = True
 
+    def disableNotify(self):
+        url = self._resource.url()
+        self.log_debug("disableNotify: %s" % (url,))
+        self._notify = False
+
     def _newCacheToken(self):
         return str(uuid.uuid4())
 
-
     def changed(self):
         """
         Change the cache token for a resource
@@ -92,8 +101,11 @@
         url = self._resource.url()
 
         if config.Notifications["Enabled"]:
-            self.log_debug("Notifications are enabled: %s" % (url,))
-            self.sendNotification(url)
+            if self._notify:
+                self.log_debug("Notifications are enabled: %s" % (url,))
+                self.sendNotification(url)
+            else:
+                self.log_debug("Skipping notification for: %s" % (url,))
 
         self.log_debug("Changing Cache Token for %r" % (url,))
         return self.getCachePool().set(

Modified: CalendarServer/trunk/twistedcaldav/directory/calendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/calendar.py	2008-08-29 20:08:40 UTC (rev 2915)
+++ CalendarServer/trunk/twistedcaldav/directory/calendar.py	2008-08-29 20:55:10 UTC (rev 2916)
@@ -279,12 +279,10 @@
             self.putChild(name, child)
 
     def provisionDefaultCalendars(self):
-        self.provision()
 
-        childName = "calendar"
-        childURL = joinURL(self.url(), childName)
-        child = self.provisionChild(childName)
-        assert isinstance(child, CalDAVResource), "Child %r is not a %s: %r" % (childName, CalDAVResource.__name__, child)
+        # Disable notifications during provisioning
+        if hasattr(self, "cacheNotifier"):
+            self.cacheNotifier.disableNotify()
 
         def setupFreeBusy(_):
             # Default calendar is initially opaque to freebusy
@@ -306,8 +304,28 @@
 
             return self
 
-        d = child.createCalendarCollection()
-        d.addCallback(setupFreeBusy)
+        try:
+            self.provision()
+
+            childName = "calendar"
+            childURL = joinURL(self.url(), childName)
+            child = self.provisionChild(childName)
+            assert isinstance(child, CalDAVResource), "Child %r is not a %s: %r" % (childName, CalDAVResource.__name__, child)
+
+            d = child.createCalendarCollection()
+            d.addCallback(setupFreeBusy)
+        except:
+            # We want to make sure to re-enable notifications, so do so
+            # if there is an immediate exception above, or via errback, below
+            if hasattr(self, "cacheNotifier"):
+                self.cacheNotifier.enableNotify(None)
+            raise
+
+        # Re-enable notifications
+        if hasattr(self, "cacheNotifier"):
+            d.addCallback(self.cacheNotifier.enableNotify)
+            d.addErrback(self.cacheNotifier.enableNotify)
+
         return d
 
     def provisionChild(self, name):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080829/7ef4496e/attachment-0001.html 


More information about the calendarserver-changes mailing list