[CalendarServer-changes] [10774] CalendarServer/trunk/twext/who

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 21 10:11:05 PST 2013


Revision: 10774
          http://trac.calendarserver.org//changeset/10774
Author:   wsanchez at apple.com
Date:     2013-02-21 10:11:04 -0800 (Thu, 21 Feb 2013)
Log Message:
-----------
Check for overlapping record types.

Modified Paths:
--------------
    CalendarServer/trunk/twext/who/aggregate.py
    CalendarServer/trunk/twext/who/idirectory.py

Modified: CalendarServer/trunk/twext/who/aggregate.py
===================================================================
--- CalendarServer/trunk/twext/who/aggregate.py	2013-02-21 18:10:24 UTC (rev 10773)
+++ CalendarServer/trunk/twext/who/aggregate.py	2013-02-21 18:11:04 UTC (rev 10774)
@@ -29,6 +29,7 @@
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.internet.defer import gatherResults
 
+from twext.who.idirectory import DirectoryConfigurationError
 from twext.who.idirectory import IDirectoryService
 from twext.who.index import DirectoryService as BaseDirectoryService
 from twext.who.index import DirectoryRecord
@@ -40,10 +41,19 @@
     """
 
     def __init__(self, realmName, services):
+        recordTypes = set()
+
         for service in services:
             if not IDirectoryService.implementedBy(service):
                 raise ValueError("Not a directory service: %s" % (service,))
 
+            for recordType in service.recordTypes():
+                if recordType in recordTypes:
+                    raise DirectoryConfigurationError(
+                        "Aggregated services may not vend the same record type: %s"
+                        % (recordType,)
+                    )
+
         BaseDirectoryService.__init__(self, realmName)
 
         self._services = tuple(services)

Modified: CalendarServer/trunk/twext/who/idirectory.py
===================================================================
--- CalendarServer/trunk/twext/who/idirectory.py	2013-02-21 18:10:24 UTC (rev 10773)
+++ CalendarServer/trunk/twext/who/idirectory.py	2013-02-21 18:11:04 UTC (rev 10774)
@@ -20,6 +20,7 @@
 
 __all__ = [
     "DirectoryServiceError",
+    "DirectoryConfigurationError",
     "DirectoryAvailabilityError",
     "UnknownRecordTypeError",
     "QueryNotSupportedError",
@@ -49,6 +50,11 @@
     Directory service generic error.
     """
 
+class DirectoryConfigurationError(DirectoryServiceError):
+    """
+    Directory configurtion error.
+    """
+
 class DirectoryAvailabilityError(DirectoryServiceError):
     """
     Directory not available.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130221/1c5278ae/attachment.html>


More information about the calendarserver-changes mailing list