[CalendarServer-changes] [13145] CalendarServer/branches/users/sagen/move2who-4

source_changes at macosforge.org source_changes at macosforge.org
Thu Apr 3 13:33:05 PDT 2014


Revision: 13145
          http://trac.calendarserver.org//changeset/13145
Author:   sagen at apple.com
Date:     2014-04-03 13:33:05 -0700 (Thu, 03 Apr 2014)
Log Message:
-----------
Fix principal.groupMemberships() to include delegate sub-principal groups

Modified Paths:
--------------
    CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/principal.py
    CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/scheduling/itip.py
    CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/scheduling/scheduler.py
    CalendarServer/branches/users/sagen/move2who-4/txdav/dps/client.py

Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/principal.py	2014-04-03 17:59:12 UTC (rev 13144)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/principal.py	2014-04-03 20:33:05 UTC (rev 13145)
@@ -55,6 +55,7 @@
 from twistedcaldav.extensions import DirectoryElement
 from twistedcaldav.resource import CalendarPrincipalCollectionResource, CalendarPrincipalResource
 from txdav.caldav.datastore.scheduling.cuaddress import normalizeCUAddr
+from txdav.who.delegates import RecordType as DelegateRecordType
 from txdav.who.directory import CalendarDirectoryRecordMixin
 from txdav.xml import element as davxml
 from txweb2 import responsecode
@@ -1003,20 +1004,28 @@
         proxyFors = set()
 
         if config.EnableProxyPrincipals:
-            childName = "calendar-proxy-{rw}-for".format(
-                rw=("write" if readWrite else "read")
+            proxyRecordType = (
+                DelegateRecordType.writeDelegatorGroup if readWrite else
+                DelegateRecordType.readDelegatorGroup
             )
-            proxyForGroup = yield self.getChild(childName)
-            if proxyForGroup:
-                proxyFors = yield proxyForGroup.groupMembers()
+            proxyGroupRecord = yield self.record.service.recordWithShortName(
+                proxyRecordType, self.record.uid
+            )
+            if proxyGroupRecord is not None:
+                proxyForRecords = yield proxyGroupRecord.members()
 
                 uids = set()
-                for principal in tuple(proxyFors):
-                    if principal.principalUID() in uids:
-                        proxyFors.remove(principal)
+                for record in tuple(proxyForRecords):
+                    if record.uid in uids:
+                        proxyForRecords.remove(record)
                     else:
-                        uids.add(principal.principalUID())
+                        uids.add(record.uid)
 
+                for record in proxyForRecords:
+                    principal = yield self.parent.principalForRecord(record)
+                    if principal is not None:
+                        proxyFors.add(principal)
+
         returnValue(proxyFors)
 
 
@@ -1062,32 +1071,20 @@
     @inlineCallbacks
     def groupMemberships(self, infinity=False):
 
-        # cache = getattr(self.record.service, "groupMembershipCache", None)
-        # if cache:
-        #     log.debug("groupMemberships is using groupMembershipCache")
-        #     guids = (yield self.record.cachedGroups())
-        #     groups = set()
-        #     for guid in guids:
-        #         principal = yield self.parent.principalForUID(guid)
-        #         if principal:
-        #             groups.add(principal)
-        # else:
         groups = yield self._getRelatives("groups", infinity=infinity)
 
-        # MOVE2WHO
-        # if config.EnableProxyPrincipals:
-        #     # Get proxy group UIDs and map to principal resources
-        #     proxies = []
-        #     memberships = (yield self._calendar_user_proxy_index().getMemberships(self.principalUID()))
-        #     for uid in memberships:
-        #         subprincipal = yield self.parent.principalForUID(uid)
-        #         if subprincipal:
-        #             proxies.append(subprincipal)
-        #         else:
-        #             yield self._calendar_user_proxy_index().removeGroup(uid)
+        if config.EnableProxyPrincipals:
+            for readWrite, proxyType in (
+                (True, "calendar-proxy-write"),
+                (False, "calendar-proxy-read")
+            ):
+                proxyFors = yield self.proxyFor(readWrite)
+                for proxyFor in proxyFors:
+                    subPrincipal = yield self.parent.principalForUID(
+                        "{}#{}".format(proxyFor.record.uid, proxyType)
+                    )
+                    groups.add(subPrincipal)
 
-        #     groups.update(proxies)
-
         returnValue(groups)
 
 
@@ -1452,7 +1449,6 @@
         if config.EnableProxyPrincipals:
             return (
                 "calendar-proxy-read", "calendar-proxy-write",
-                "calendar-proxy-read-for", "calendar-proxy-write-for",
             )
         else:
             return ()

Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/scheduling/itip.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/scheduling/itip.py	2014-04-03 17:59:12 UTC (rev 13144)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/scheduling/itip.py	2014-04-03 20:33:05 UTC (rev 13145)
@@ -42,6 +42,7 @@
     "iTipGenerator",
 ]
 
+
 class iTipProcessing(object):
 
     @staticmethod
@@ -951,8 +952,6 @@
     @staticmethod
     def generateAttendeeReply(original, attendee, changedRids=None, force_decline=False):
 
-        print("XYZZY generateAttendeeReply", original, attendee)
-
         # Start with a copy of the original as we may have to modify bits of it
         itip = original.duplicate()
         itip.replaceProperty(Property("PRODID", iCalendarProductID))
@@ -972,7 +971,6 @@
             if component.name() in ignoredComponents:
                 continue
             if not component.getAttendeeProperty((attendee,)):
-                print("XYZZY removing componeont", component, attendee)
                 itip.removeComponent(component)
 
         # No alarms
@@ -1018,7 +1016,6 @@
             if component.name() == "VPOLL":
                 iTipGenerator.generateVPOLLReply(component, attendee)
 
-        print("XYZZY AFTER", itip)
         return itip
 
 

Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/scheduling/scheduler.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/scheduling/scheduler.py	2014-04-03 17:59:12 UTC (rev 13144)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/scheduling/scheduler.py	2014-04-03 20:33:05 UTC (rev 13145)
@@ -320,10 +320,6 @@
             # Verify that there is a single ATTENDEE property
             attendees = self.calendar.getAttendees()
 
-            # FIXME, how can this be None?
-            if attendees is None:
-                print("XYZZY Attendees is None", self.calendar)
-
             # Must have only one
             if len(attendees) != 1:
                 log.error("Wrong number of ATTENDEEs in calendar data: %s" % (str(self.calendar),))

Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/dps/client.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/txdav/dps/client.py	2014-04-03 17:59:12 UTC (rev 13144)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/dps/client.py	2014-04-03 20:33:05 UTC (rev 13145)
@@ -59,15 +59,12 @@
 
 ## MOVE2WHO TODOs:
 ## SACLs
-## Wiki
 ## LDAP
 ## Tests from old twistedcaldav/directory
 ## Cmd line tools
 ## Store based directory service (records in the store, i.e.
 ##    locations/resources)
 ## Separate store for DPS (augments and delegates separate from calendar data)
-## calverify needs deferreds, including:
-##    component.normalizeCalendarUserAddresses
 ## Store autoAcceptGroups in the group db?
 
 @implementer(IDirectoryService, IStoreDirectoryService)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140403/599e6c93/attachment.html>


More information about the calendarserver-changes mailing list