[Zodb-checkins] CVS: Zope3/src/zope/interface - adapter.py:1.17

Jim Fulton jim at zope.com
Tue Apr 20 07:38:07 EDT 2004


Update of /cvs-repository/Zope3/src/zope/interface
In directory cvs.zope.org:/tmp/cvs-serv11058/src/zope/interface

Modified Files:
	adapter.py 
Log Message:
Now allow None to be specified for any of the required interfaces.


=== Zope3/src/zope/interface/adapter.py 1.16 => 1.17 ===
--- Zope3/src/zope/interface/adapter.py:1.16	Thu Apr 15 11:29:53 2004
+++ Zope3/src/zope/interface/adapter.py	Tue Apr 20 07:38:04 2004
@@ -85,7 +85,7 @@
 from sets import Set
 from zope.interface.ro import ro
 from zope.interface.declarations import providedBy
-from zope.interface.interface import InterfaceClass
+from zope.interface.interface import InterfaceClass, Interface
 
 Default = InterfaceClass("Default", (), {})
 Null = InterfaceClass("Null", (), {})
@@ -251,7 +251,6 @@
     def __repr__(self):
         return '<%s(%s)>' % (self.__class__.__name__, self.spec())
 
-
 def orderwith(bywith):
 
     # Convert {with -> adapter} to withs, [(with, value)]
@@ -269,6 +268,7 @@
             
     return withs
     
+
 def withextends(with1, with2):
     for spec1, spec2 in zip(with1, with2):
         if spec1.extends(spec2):
@@ -318,10 +318,16 @@
 
     def register(self, required, provided, name, value):
         if required:
-            required, with = self.get(required[0]), tuple(required[1:])
+            with = []
+            for iface in required[1:]:
+                if iface is None:
+                    iface = Interface
+                with.append(iface)
+            with = tuple(with)
+            required = self.get(required[0])
         else:
-            required = self._null
             with = ()
+            required = self._null
         
         if not isinstance(name, basestring):
             raise TypeError("The name provided to provideAdapter "




More information about the Zodb-checkins mailing list