[CalendarServer-changes] [7273] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Mar 29 13:10:22 PDT 2011


Revision: 7273
          http://trac.macosforge.org/projects/calendarserver/changeset/7273
Author:   cdaboo at apple.com
Date:     2011-03-29 13:10:22 -0700 (Tue, 29 Mar 2011)
Log Message:
-----------
Make sure that PROPFIND cache is invalidated by notification collection changes.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/provision/root.py
    CalendarServer/trunk/twistedcaldav/resource.py
    CalendarServer/trunk/twistedcaldav/sharing.py
    CalendarServer/trunk/twistedcaldav/storebridge.py
    CalendarServer/trunk/txdav/common/datastore/sql.py

Modified: CalendarServer/trunk/calendarserver/provision/root.py
===================================================================
--- CalendarServer/trunk/calendarserver/provision/root.py	2011-03-29 20:09:34 UTC (rev 7272)
+++ CalendarServer/trunk/calendarserver/provision/root.py	2011-03-29 20:10:22 UTC (rev 7273)
@@ -40,7 +40,7 @@
 from twistedcaldav.resource import CalendarHomeResource, AddressBookHomeResource
 from twistedcaldav.directory.principal import DirectoryPrincipalResource
 from twistedcaldav.storebridge import CalendarCollectionResource,\
-    AddressBookCollectionResource
+    AddressBookCollectionResource, StoreNotificationCollectionResource
 
 log = Logger()
 
@@ -90,6 +90,7 @@
             DirectoryPrincipalResource.cacheNotifierFactory = MemcacheChangeNotifier
             CalendarCollectionResource.cacheNotifierFactory = MemcacheChangeNotifier
             AddressBookCollectionResource.cacheNotifierFactory = MemcacheChangeNotifier
+            StoreNotificationCollectionResource.cacheNotifierFactory = MemcacheChangeNotifier
         else:
             self.responseCache = DisabledCache()
 

Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py	2011-03-29 20:09:34 UTC (rev 7272)
+++ CalendarServer/trunk/twistedcaldav/resource.py	2011-03-29 20:10:22 UTC (rev 7273)
@@ -2153,6 +2153,7 @@
         from twistedcaldav.storebridge import StoreNotificationCollectionResource
         similar = StoreNotificationCollectionResource(
             notifications,
+            self,
             self._newStoreHome,
             principalCollections = self.principalCollections(),
         )

Modified: CalendarServer/trunk/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/sharing.py	2011-03-29 20:09:34 UTC (rev 7272)
+++ CalendarServer/trunk/twistedcaldav/sharing.py	2011-03-29 20:10:22 UTC (rev 7273)
@@ -549,10 +549,11 @@
         sharee = self.principalForCalendarUserAddress(record.userid)
         if sharee is None:
             raise ValueError("sharee is None but userid was valid before")
-        notifications = yield self._associatedTransaction.notificationsWithUID(
-            sharee.principalUID()
-        )
         
+        # We need to look up the resource so that the response cache notifier is properly initialized
+        notificationResource = (yield request.locateResource(sharee.notificationURL()))
+        notifications = notificationResource._newStoreNotifications
+        
         # Look for existing notification
         oldnotification = (yield notifications.notificationObjectWithUID(record.inviteuid))
         if oldnotification:

Modified: CalendarServer/trunk/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/storebridge.py	2011-03-29 20:09:34 UTC (rev 7272)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py	2011-03-29 20:10:22 UTC (rev 7273)
@@ -2053,23 +2053,33 @@
 
 
 class StoreNotificationCollectionResource(_NotificationChildHelper,
-                                      NotificationCollectionResource):
+                                          NotificationCollectionResource,
+                                          ResponseCacheMixin):
     """
     Wrapper around a L{txdav.caldav.icalendar.ICalendar}.
     """
 
-    def __init__(self, notifications, home, *args, **kw):
+    cacheNotifierFactory = DisabledCacheNotifier
+
+    def __init__(self, notifications, homeResource, home, *args, **kw):
         """
         Create a CalendarCollectionResource from a L{txdav.caldav.icalendar.ICalendar}
         and the arguments required for L{CalDAVResource}.
         """
         super(StoreNotificationCollectionResource, self).__init__(*args, **kw)
         self._initializeWithNotifications(notifications, home)
+        self._parentResource = homeResource
+        if self._newStoreNotifications:
+            self.cacheNotifier = self.cacheNotifierFactory(self)
+            self._newStoreNotifications.addNotifier(CacheStoreNotifier(self))
 
 
     def name(self):
         return "notification"
 
+    def url(self):
+        return joinURL(self._parentResource.url(), self.name(), "/")
+
     @inlineCallbacks
     def listChildren(self):
         l = []

Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py	2011-03-29 20:09:34 UTC (rev 7272)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py	2011-03-29 20:10:22 UTC (rev 7273)
@@ -2628,6 +2628,11 @@
         return self._propertyStore
 
 
+    def addNotifier(self, notifier):
+        if self._notifiers is None:
+            self._notifiers = ()
+        self._notifiers += (notifier,)
+ 
     def notifierID(self, label="default"):
         if self._notifiers:
             return self._notifiers[0].getID(label)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110329/770b59aa/attachment.html>


More information about the calendarserver-changes mailing list