[CalendarServer-changes] [13128] CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/ directory

source_changes at macosforge.org source_changes at macosforge.org
Wed Apr 2 13:30:54 PDT 2014


Revision: 13128
          http://trac.calendarserver.org//changeset/13128
Author:   sagen at apple.com
Date:     2014-04-02 13:30:54 -0700 (Wed, 02 Apr 2014)
Log Message:
-----------
Don't list children of /addressbooks/ and /calendars/ which don't apply.

Modified Paths:
--------------
    CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/addressbook.py
    CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/calendar.py

Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/addressbook.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/addressbook.py	2014-04-02 19:13:50 UTC (rev 13127)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/addressbook.py	2014-04-02 20:30:54 UTC (rev 13128)
@@ -100,19 +100,32 @@
         # FIXME: Smells like a hack
         directory.addressBookHomesCollection = self
 
+
         #
         # Create children
         #
-        # ...just "users" though.  If we iterate all of the directory's
-        # recordTypes, we also get the proxy sub principal types.
+        # ...just users, locations, and resources though.  If we iterate all of
+        # the directory's recordTypes, we also get the proxy sub principal types
+        # and other things which don't have addressbooks.
+
+        self.supportedChildTypes = (
+            self.directory.recordType.user,
+            self.directory.recordType.location,
+            self.directory.recordType.resource,
+        )
+
         for recordTypeName in [
-            self.directory.recordTypeToOldName(r) for r in [
-                self.directory.recordType.user
-            ]
+            self.directory.recordTypeToOldName(r) for r in
+            self.supportedChildTypes
         ]:
             # FIXME: why don't we also pass in the name to the resource itself
             # like we do for DirectoryCalendarHomeTypeProvisioningResource?
-            self.putChild(recordTypeName, DirectoryAddressBookHomeTypeProvisioningResource(self, r))
+            self.putChild(
+                recordTypeName,
+                DirectoryAddressBookHomeTypeProvisioningResource(
+                    self, recordTypeName, r
+                )
+            )
 
         self.putChild(uidsResourceName, DirectoryAddressBookHomeUIDProvisioningResource(self))
 
@@ -122,7 +135,10 @@
 
 
     def listChildren(self):
-        return [self.directory.recordTypeToOldName(r) for r in self.directory.recordTypes()]
+        return [
+            self.directory.recordTypeToOldName(r) for r in
+            self.supportedChildTypes
+        ]
 
 
     def principalCollections(self):
@@ -167,23 +183,25 @@
     Resource which provisions address book home collections of a specific
     record type as needed.
     """
-    def __init__(self, parent, recordType):
+    def __init__(self, parent, name, recordType):
         """
         @param parent: the parent of this resource
         @param recordType: the directory record type to provision.
         """
         assert parent is not None
+        assert name is not None
         assert recordType is not None
 
         super(DirectoryAddressBookHomeTypeProvisioningResource, self).__init__()
 
         self.directory = parent.directory
+        self.name = name
         self.recordType = recordType
         self._parent = parent
 
 
     def url(self):
-        return joinURL(self._parent.url(), self.directory.recordTypeToOldName(self.recordType))
+        return joinURL(self._parent.url(), self.name)
 
 
     @inlineCallbacks

Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/calendar.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/calendar.py	2014-04-02 19:13:50 UTC (rev 13127)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/calendar.py	2014-04-02 20:30:54 UTC (rev 13128)
@@ -104,14 +104,26 @@
         #
         # Create children
         #
-        # ...just "users" though.  If we iterate all of the directory's
-        # recordTypes, we also get the proxy sub principal types.
+        # ...just users, locations, and resources though.  If we iterate all of
+        # the directory's recordTypes, we also get the proxy sub principal types
+        # and other things which don't have calendars.
+
+        self.supportedChildTypes = (
+            self.directory.recordType.user,
+            self.directory.recordType.location,
+            self.directory.recordType.resource,
+        )
+
         for recordTypeName in [
-            self.directory.recordTypeToOldName(r) for r in [
-                self.directory.recordType.user
-            ]
+            self.directory.recordTypeToOldName(r) for r in
+            self.supportedChildTypes
         ]:
-            self.putChild(recordTypeName, DirectoryCalendarHomeTypeProvisioningResource(self, recordTypeName, r))
+            self.putChild(
+                recordTypeName,
+                DirectoryCalendarHomeTypeProvisioningResource(
+                    self, recordTypeName, r
+                )
+            )
 
         self.putChild(uidsResourceName, DirectoryCalendarHomeUIDProvisioningResource(self))
 
@@ -121,7 +133,10 @@
 
 
     def listChildren(self):
-        return [self.directory.recordTypeToOldName(r) for r in self.directory.recordTypes()]
+        return [
+            self.directory.recordTypeToOldName(r) for r in
+            self.supportedChildTypes
+        ]
 
 
     def principalCollections(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140402/0e6ccf61/attachment-0001.html>


More information about the calendarserver-changes mailing list