[CalendarServer-changes] [11256] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Wed May 29 13:37:23 PDT 2013
Revision: 11256
http://trac.calendarserver.org//changeset/11256
Author: cdaboo at apple.com
Date: 2013-05-29 13:37:23 -0700 (Wed, 29 May 2013)
Log Message:
-----------
Fix failure to invalidate cached PROPFIND Depth:0 on homes.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/cache.py
CalendarServer/trunk/twistedcaldav/test/test_cache.py
Modified: CalendarServer/trunk/twistedcaldav/cache.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/cache.py 2013-05-29 19:02:14 UTC (rev 11255)
+++ CalendarServer/trunk/twistedcaldav/cache.py 2013-05-29 20:37:23 UTC (rev 11256)
@@ -517,9 +517,12 @@
self._storeObject = storeObject
+ @inlineCallbacks
def notify(self):
"""
We need to convert the store object notifier ID into a URI, since the cache uses URIs.
+ Note that for a home child resource we also need to change the token for the home as the
+ sync token on the home changes implicitly without a direct notification.
"""
prefix, id = self._storeObject.notifierID()
@@ -527,9 +530,20 @@
uri = "/calendars/__uids__/%s/" % (id,)
elif prefix == "CardDAV":
uri = "/addressbooks/__uids__/%s/" % (id,)
- uri = urllib.quote(uri)
- return self._notifierFactory.changed(uri)
+ uris = (urllib.quote(uri),)
+ # Also add home if needed
+ if "/" in id:
+ id = id.split("/")[0]
+ if prefix == "CalDAV":
+ uri = "/calendars/__uids__/%s/" % (id,)
+ elif prefix == "CardDAV":
+ uri = "/addressbooks/__uids__/%s/" % (id,)
+ uris += (urllib.quote(uri),)
+ for uri in uris:
+ yield self._notifierFactory.changed(uri)
+
+
def clone(self, storeObject):
return self.__class__(self._notifierFactory, storeObject)
Modified: CalendarServer/trunk/twistedcaldav/test/test_cache.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_cache.py 2013-05-29 19:02:14 UTC (rev 11255)
+++ CalendarServer/trunk/twistedcaldav/test/test_cache.py 2013-05-29 20:37:23 UTC (rev 11256)
@@ -18,7 +18,7 @@
import hashlib
import cPickle
-from twisted.internet.defer import succeed, maybeDeferred
+from twisted.internet.defer import succeed, maybeDeferred, inlineCallbacks
from twext.python.log import LogLevel
from twext.web2.dav.util import allDataFromStream
@@ -27,7 +27,7 @@
from txdav.xml import element as davxml
-from twistedcaldav.cache import MemcacheResponseCache
+from twistedcaldav.cache import MemcacheResponseCache, CacheStoreNotifier
from twistedcaldav.cache import MemcacheChangeNotifier
from twistedcaldav.cache import PropfindCacheMixin
@@ -497,6 +497,48 @@
+class TestCacheStoreNotifier(TestCase):
+
+ @inlineCallbacks
+ def test_notify_home_child(self):
+ """
+ Verify that L{CacheStoreNotifier.notify} will generate notifications for homes and home childs.
+ """
+
+ class StubCacheStoreNotifierFactory(object):
+
+ def __init__(self):
+ self.results = set()
+
+ def changed(self, uri):
+ self.results.add(uri)
+ return succeed(None)
+
+
+ class StubCacheResource(object):
+
+ def __init__(self, notifierID):
+ self.nid = notifierID
+
+ def notifierID(self):
+ return self.nid
+
+ data = (
+ (("CalDAV", "user01"), ("/calendars/__uids__/user01/",),),
+ (("CalDAV", "user01/calendar"), ("/calendars/__uids__/user01/", "/calendars/__uids__/user01/calendar/",),),
+ (("CardDAV", "user01"), ("/addressbooks/__uids__/user01/",),),
+ (("CardDAV", "user01/calendar"), ("/addressbooks/__uids__/user01/", "/calendars/__uids__/user01/calendar/",),),
+ )
+
+ for item, results in data:
+ factory = StubCacheStoreNotifierFactory()
+ notifier = CacheStoreNotifier(factory, StubCacheResource(item))
+ yield notifier.notify()
+
+ self.assertEqual(factory.results, set(results))
+
+
+
class PropfindCacheMixinTests(TestCase):
"""
Test the PropfindCacheMixin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130529/29ad0fea/attachment.html>
More information about the calendarserver-changes
mailing list