[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/container/contained.py When adding an interface directly, keep the old ones...

Florent Guillaume fg at nuxeo.com
Mon Oct 11 07:53:08 EDT 2004


Log message for revision 27966:
  When adding an interface directly, keep the old ones...
  directlyProvides is dangerous...
  


Changed:
  U   Zope3/trunk/src/zope/app/container/contained.py


-=-
Modified: Zope3/trunk/src/zope/app/container/contained.py
===================================================================
--- Zope3/trunk/src/zope/app/container/contained.py	2004-10-11 11:51:43 UTC (rev 27965)
+++ Zope3/trunk/src/zope/app/container/contained.py	2004-10-11 11:53:08 UTC (rev 27966)
@@ -302,11 +302,27 @@
         True
         >>> x.__name__
         'foo'
+
+    Make sure we don't lose existing directly provided interfaces.
+
+        >>> from zope.interface import Interface, directlyProvides
+        >>> class IOther(Interface):
+        ...     pass
+        >>> from zope.app.location import Location
+        >>> item = Location()
+        >>> directlyProvides(item, IOther)
+        >>> IOther.providedBy(item)
+        True
+        >>> x, event = containedEvent(item, container, 'foo')
+        >>> IOther.providedBy(item)
+        True
     """
 
     if not IContained.providedBy(object):
         if ILocation.providedBy(object):
-            zope.interface.directlyProvides(object, IContained)
+            zope.interface.directlyProvides(
+                object, IContained,
+                zope.interface.directlyProvidedBy(object))
         else:
             object = ContainedProxy(object)
 



More information about the Zope3-Checkins mailing list