[Zope3-checkins] CVS: Zope3/src/zope/app/tests - ztapi.py:1.6

Jim Fulton jim at zope.com
Mon Mar 15 15:42:21 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/tests
In directory cvs.zope.org:/tmp/cvs-serv3730/src/zope/app/tests

Modified Files:
	ztapi.py 
Log Message:
Changed to disallow multiple factories to be provided.

Allow single required interface in registration.


=== Zope3/src/zope/app/tests/ztapi.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/tests/ztapi.py:1.5	Fri Mar  5 21:46:20 2004
+++ Zope3/src/zope/app/tests/ztapi.py	Mon Mar 15 15:42:20 2004
@@ -24,18 +24,24 @@
                 providing=zope.interface.Interface):
     """Define a global browser view
     """
+    if isinstance(factory, (list, tuple)):
+        raise ValueError("Factory cannot be a list or tuple")
     s = zapi.getService(None, Presentation)
     return s.provideView(for_, name, IBrowserRequest, factory, layer,
                          providing=providing)
 
 def browserViewProviding(for_, factory, providing, layer='default'):
     """Define a view providing a particular interface."""
+    if isinstance(factory, (list, tuple)):
+        raise ValueError("Factory cannot be a list or tuple")
     return browserView(for_, '', factory, layer, providing)
 
 def browserResource(name, factory, layer='default',
                     providing=zope.interface.Interface):
     """Define a global browser view
     """
+    if isinstance(factory, (list, tuple)):
+        raise ValueError("Factory cannot be a list or tuple")
     s = zapi.getService(None, Presentation)
     return s.provideResource(name, IBrowserRequest, factory, layer,
                              providing=providing)
@@ -46,10 +52,16 @@
 
 stypes = list, tuple
 def provideAdapter(required, provided, factory, name='', with=()):
+    if isinstance(factory, (list, tuple)):
+        raise ValueError("Factory cannot be a list or tuple")
     s = zapi.getService(None, Adapters)
-    if not isinstance(factory, stypes):
-        factory = [factory]
-    s.provideAdapter(required, provided, factory, name, with)
+
+    if with:
+        required = (required, ) + tuple(with)
+    elif not isinstance(required, stypes):
+        required = [required]
+            
+    s.register(required, provided, name, factory)
     
 def provideUtility(provided, component, name=''):
     s = zapi.getService(None, Utilities)




More information about the Zope3-Checkins mailing list