[CalendarServer-changes] [1716] CalendarServer/branches/users/wsanchez/guid-cleanup/twistedcaldav/ directory

source_changes at macosforge.org source_changes at macosforge.org
Thu Jul 26 14:45:38 PDT 2007


Revision: 1716
          http://trac.macosforge.org/projects/calendarserver/changeset/1716
Author:   wsanchez at apple.com
Date:     2007-07-26 14:45:38 -0700 (Thu, 26 Jul 2007)

Log Message:
-----------
Revert r1643

Modified Paths:
--------------
    CalendarServer/branches/users/wsanchez/guid-cleanup/twistedcaldav/directory/calendaruserproxy.py
    CalendarServer/branches/users/wsanchez/guid-cleanup/twistedcaldav/directory/principal.py

Modified: CalendarServer/branches/users/wsanchez/guid-cleanup/twistedcaldav/directory/calendaruserproxy.py
===================================================================
--- CalendarServer/branches/users/wsanchez/guid-cleanup/twistedcaldav/directory/calendaruserproxy.py	2007-07-26 21:44:56 UTC (rev 1715)
+++ CalendarServer/branches/users/wsanchez/guid-cleanup/twistedcaldav/directory/calendaruserproxy.py	2007-07-26 21:45:38 UTC (rev 1716)
@@ -78,8 +78,6 @@
     Calendar user proxy principal resource.
     """
 
-    guidMapper = {}    # dict to map a GUID to a proxy principal
-
     def davComplianceClasses(self):
         return tuple(super(CalendarUserProxyPrincipalResource, self).davComplianceClasses()) + (
             "calendar-access",
@@ -103,7 +101,6 @@
         if self.isCollection():
             self._url += "/"
         self.guid = uuidFromName(self.parent.principalUID(), proxyType)
-        self.guidMapper[self.guid] = self
 
         # Provision in __init__() because principals are used prior to request
         # lookups.
@@ -121,10 +118,6 @@
             setattr(self.pcollection, "calendar_user_proxy_db", CalendarUserProxyDatabase(self.pcollection.fp.path))
         return self.pcollection.calendar_user_proxy_db
 
-    @classmethod
-    def principalForGUID(cls, guid):
-        return cls.guidMapper.get(guid)
-
     def resourceType(self):
         if self.proxyType == "calendar-proxy-read":
             return davxml.ResourceType.calendarproxyread

Modified: CalendarServer/branches/users/wsanchez/guid-cleanup/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/wsanchez/guid-cleanup/twistedcaldav/directory/principal.py	2007-07-26 21:44:56 UTC (rev 1715)
+++ CalendarServer/branches/users/wsanchez/guid-cleanup/twistedcaldav/directory/principal.py	2007-07-26 21:45:38 UTC (rev 1716)
@@ -100,8 +100,6 @@
         record = self.directory.recordWithGUID(guid)
         if record:
             return self.principalForRecord(record)
-        elif config.EnableProxyPrincipals:
-            return CalendarUserProxyPrincipalResource.principalForGUID(guid)
         else:
             return None
 
@@ -402,6 +400,32 @@
             setattr(pcollection, "calendar_user_proxy_db", CalendarUserProxyDatabase(pcollection.fp.path))
         return pcollection.calendar_user_proxy_db
 
+    def _map_calendar_user_proxy_guids(self, guids):
+        """
+        Return a list of principals mapped from a list of calendar user proxy principal GUIDs.
+        
+        @param guids: a C{list} of C{str}'s containing the GUIDs to map.
+        @return: a C{list} of L{CalendarPrincipalResource}s for each mapped GUID.
+        """
+        proxies = []
+        for guid in guids:
+            # Get the "base" GUID for the parent of the proxy principal
+            if guid.endswith("-calendar-proxy-read"):
+                guid = guid[:-20]
+                proxyType = "calendar-proxy-read"
+            elif guid.endswith("-calendar-proxy-write"):
+                guid = guid[:-21]
+                proxyType = "calendar-proxy-write"
+                
+            # Lookup the base GUID and get its principal resource
+            principal = self.parent.principalForGUID(guid)
+            if principal:
+                proxyprincipal = principal.getChild(proxyType)
+                if proxyprincipal:
+                    proxies.append(proxyprincipal)
+                    
+        return proxies
+            
     def groupMembers(self):
         return self._getRelatives("members")
 
@@ -413,7 +437,7 @@
             groups.update(self._getRelatives("proxyFor", proxy=True))
 
             # Get proxy group GUIDs and map to principal resources
-            proxies = [self.parent.principalForGUID(guid) for guid in self._calendar_user_proxy_index().getMemberships(self.principalUID())]
+            proxies = self._map_calendar_user_proxy_guids(self._calendar_user_proxy_index().getMemberships(self.principalUID()))
             groups.update(proxies)
 
         return groups

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


More information about the calendarserver-changes mailing list