[CalendarServer-changes] [10735] CalendarServer/trunk/twext/who/util.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Feb 15 11:58:51 PST 2013


Revision: 10735
          http://trac.calendarserver.org//changeset/10735
Author:   wsanchez at apple.com
Date:     2013-02-15 11:58:51 -0800 (Fri, 15 Feb 2013)
Log Message:
-----------
Don't allow conflicting constant names. Avoid nesting.

Modified Paths:
--------------
    CalendarServer/trunk/twext/who/util.py

Modified: CalendarServer/trunk/twext/who/util.py
===================================================================
--- CalendarServer/trunk/twext/who/util.py	2013-02-14 22:07:56 UTC (rev 10734)
+++ CalendarServer/trunk/twext/who/util.py	2013-02-15 19:58:51 UTC (rev 10735)
@@ -39,8 +39,25 @@
     and doesn't provide a way to merge multiple Names classes.
     """
     def __init__(self, *containers):
-        self._containers = containers
+        seenNames = set()
+        myContainers = set()
+        for container in containers:
+            for constant in container.iterconstants():
+                if constant.name in seenNames:
+                    raise ValueError(
+                        "Multiple constants with the same name may not be merged: %s"
+                        % (constant.name,)
+                    )
+                seenNames.add(constant.name)
 
+            if isinstance(container, MergedConstants):
+                # Avoid nesting
+                myContainers |= container._containers
+            else:
+                myContainers.add(container)
+
+        self._containers = myContainers
+
     def __getattr__(self, name):
         for container in self._containers:
             attr = getattr(container, name, None)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130215/0602abe2/attachment.html>


More information about the calendarserver-changes mailing list