[Zope3-checkins] SVN: Zope3/trunk/ enable multi typing within the interface directive

Dominik Huber dominik.huber at projekt01.ch
Mon Apr 25 13:08:16 EDT 2005


Log message for revision 30166:
  enable multi typing within the interface directive

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/app/component/interface.py

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2005-04-25 16:29:28 UTC (rev 30165)
+++ Zope3/trunk/doc/CHANGES.txt	2005-04-25 17:08:16 UTC (rev 30166)
@@ -591,6 +591,8 @@
 
     Bug Fixes
 
+      - The interface directive supports multiple interface types now.
+
       - Fixed issue #314: i18n:translate removes line breaks
         from <pre>...</pre> contents
 

Modified: Zope3/trunk/src/zope/app/component/interface.py
===================================================================
--- Zope3/trunk/src/zope/app/component/interface.py	2005-04-25 16:29:28 UTC (rev 30165)
+++ Zope3/trunk/src/zope/app/component/interface.py	2005-04-25 17:08:16 UTC (rev 30166)
@@ -18,7 +18,7 @@
 __docformat__ = 'restructuredtext'
 from types import ClassType
 from zope.component.exceptions import ComponentLookupError
-from zope.interface import directlyProvides
+from zope.interface import directlyProvides, directlyProvidedBy
 from zope.interface.interfaces import IInterface
 from zope.app import zapi
 
@@ -42,6 +42,8 @@
     >>> interfaces = gsm.getUtilitiesFor(IContentType)
     >>> list(interfaces)
     []
+
+    # provide first interface type
     >>> provideInterface('', I, IContentType)
     >>> IContentType.providedBy(I)
     True
@@ -50,6 +52,23 @@
     [u'zope.app.component.interface.I']
     >>> [iface.__name__ for (name, iface) in interfaces]
     ['I']
+
+    # provide second interface type
+    >>> class IOtherType(IInterface):
+    ...     pass
+    >>> provideInterface('', I, IOtherType)
+
+    >>> IContentType.providedBy(I)
+    True
+    >>> IOtherType.providedBy(I)
+    True
+    >>> interfaces = list(gsm.getUtilitiesFor(IContentType))
+    >>> [name for (name, iface) in interfaces]
+    [u'zope.app.component.interface.I']
+    >>> interfaces = list(gsm.getUtilitiesFor(IOtherType))
+    >>> [name for (name, iface) in interfaces]
+    [u'zope.app.component.interface.I']
+
     >>> class I1(Interface):
     ...     pass
     >>> provideInterface('', I1)
@@ -75,7 +94,7 @@
     if iface_type is not None:
         if not iface_type.extends(IInterface):
             raise TypeError(iface_type, "is not an interface type")
-        directlyProvides(interface, iface_type)
+        directlyProvides(interface, iface_type, directlyProvidedBy(interface))
     else:
         iface_type = IInterface
         



More information about the Zope3-Checkins mailing list