[CalendarServer-changes] [2369] CalendarServer/branches/propfind-cache/twistedcaldav/directory

source_changes at macosforge.org source_changes at macosforge.org
Mon May 5 13:38:01 PDT 2008


Revision: 2369
          http://trac.macosforge.org/projects/calendarserver/changeset/2369
Author:   dreid at apple.com
Date:     2008-05-05 13:38:00 -0700 (Mon, 05 May 2008)

Log Message:
-----------
Make setGroupMemberSet notify the caches of the principals being added to the group.

Modified Paths:
--------------
    CalendarServer/branches/propfind-cache/twistedcaldav/directory/calendaruserproxy.py
    CalendarServer/branches/propfind-cache/twistedcaldav/directory/principal.py
    CalendarServer/branches/propfind-cache/twistedcaldav/directory/test/test_proxyprincipalmembers.py

Modified: CalendarServer/branches/propfind-cache/twistedcaldav/directory/calendaruserproxy.py
===================================================================
--- CalendarServer/branches/propfind-cache/twistedcaldav/directory/calendaruserproxy.py	2008-05-05 20:11:42 UTC (rev 2368)
+++ CalendarServer/branches/propfind-cache/twistedcaldav/directory/calendaruserproxy.py	2008-05-05 20:38:00 UTC (rev 2369)
@@ -178,6 +178,7 @@
                     "Attempt to use a non-existent principal %s as a group member of %s." % (uri, self.principalURL(),)
                 ))
             principals.append(principal)
+            principal.cacheNotifier.changed()
 
         # Map the principals to UIDs.
         uids = [p.principalUID() for p in principals]

Modified: CalendarServer/branches/propfind-cache/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/propfind-cache/twistedcaldav/directory/principal.py	2008-05-05 20:11:42 UTC (rev 2368)
+++ CalendarServer/branches/propfind-cache/twistedcaldav/directory/principal.py	2008-05-05 20:38:00 UTC (rev 2369)
@@ -347,6 +347,8 @@
     """
     Directory principal resource.
     """
+    cacheNotifierFactory = CacheChangeNotifier
+
     def __init__(self, path, parent, record):
         """
         @param path: them path to the file which will back this resource.
@@ -355,7 +357,8 @@
         """
         super(DirectoryPrincipalResource, self).__init__(path)
 
-        self.cacheNotifier = CacheChangeNotifier(self.deadProperties())
+        self.cacheNotifier = self.cacheNotifierFactory(
+            self.deadProperties())
 
         if self.isCollection():
             slash = "/"

Modified: CalendarServer/branches/propfind-cache/twistedcaldav/directory/test/test_proxyprincipalmembers.py
===================================================================
--- CalendarServer/branches/propfind-cache/twistedcaldav/directory/test/test_proxyprincipalmembers.py	2008-05-05 20:11:42 UTC (rev 2368)
+++ CalendarServer/branches/propfind-cache/twistedcaldav/directory/test/test_proxyprincipalmembers.py	2008-05-05 20:38:00 UTC (rev 2369)
@@ -23,6 +23,7 @@
 from twistedcaldav.directory.xmlfile import XMLDirectoryService
 from twistedcaldav.directory.test.test_xmlfile import xmlFile
 from twistedcaldav.directory.principal import DirectoryPrincipalProvisioningResource
+from twistedcaldav.directory.principal import DirectoryPrincipalResource
 
 import twistedcaldav.test.util
 
@@ -203,16 +204,21 @@
 
         proxy_group = user.getChild("calendar-proxy-write")
 
-        proxyMember = self._getRecordByShortName(
-            directoryService.recordType_users,
-            "dreid")
+        notifier = StubCacheNotifier()
 
-        proxyMember.cacheNotifier = StubCacheNotifier()
+        oldCacheNotifier = DirectoryPrincipalResource.cacheNotifierFactory
 
-        self.assertEquals(proxyMember.cacheNotifier.changedCount, 0)
+        try:
+            DirectoryPrincipalResource.cacheNotifierFactory = (lambda _1, _2: notifier)
 
-        proxy_group.setGroupMemberSet(davxml.GroupMemberSet(
-                davxml.HRef.fromString(
-                    "/XMLDirectoryService/__uids__/%s" % (proxyMember.uid,))))
+            self.assertEquals(notifier.changedCount, 0)
 
-        self.assertEquals(proxyMember.cacheNotifier.changedCount, 1)
+            proxy_group.setGroupMemberSet(
+                davxml.GroupMemberSet(
+                    davxml.HRef.fromString(
+                        "/XMLDirectoryService/__uids__/5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1/")),
+                None)
+
+            self.assertEquals(notifier.changedCount, 1)
+        finally:
+            DirectoryPrincipalResource.cacheNotifierFactory = oldCacheNotifier

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080505/350ba64a/attachment.html


More information about the calendarserver-changes mailing list