[Zope3-checkins] CVS: Zope3/src/zope/app/presentation - presentation.py:1.10

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


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

Modified Files:
	presentation.py 
Log Message:
Reworked to reflect changes in the adapter-registry api:

- Factory semantics are now provided by layers, rather than the
  underlying adapter registries

- Added multi-view support, but need more tests to finish.

- No longer expect multiple factories


=== Zope3/src/zope/app/presentation/presentation.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/presentation/presentation.py:1.9	Sat Mar 13 23:03:31 2004
+++ Zope3/src/zope/app/presentation/presentation.py	Mon Mar 15 15:41:44 2004
@@ -30,6 +30,7 @@
 import zope.app.interface.interfaces
 import zope.app.adapter
 import zope.component.interfaces
+import zope.component.presentation
 import zope.configuration.exceptions
 import zope.interface
 import zope.proxy
@@ -179,7 +180,8 @@
                 layer = self.delegate.queryLayer(layername)
             if layer is None:
                 raise ValueError("Bad layer", layer)
-            r = layer.queryMultiAdapter(objects, IDefaultViewName, raw=True)
+            r = layer.lookup(map(zope.interface.providedBy, objects),
+                             IDefaultViewName)
             if r is not None:
                 return r
         return default
@@ -278,6 +280,7 @@
 
 class LocalLayer(
     zope.app.adapter.LocalAdapterRegistry,
+    zope.component.presentation.Layer,
     zope.app.container.contained.Contained,
     ):
 
@@ -359,10 +362,10 @@
         return (self.requestType, )
     with = property(with)
 
-    def factories(self):
+    def factory(self):
         folder = self.__parent__.__parent__
-        return (folder.resolve(self.factoryName), )
-    factories = property(factories)
+        return folder.resolve(self.factoryName)
+    factory = property(factory)
 
 class IPageRegistration(IViewRegistration):
 
@@ -381,8 +384,8 @@
         required = False,
         )
 
-    factories = zope.interface.Attribute(
-        "A sequence of factories to be called to construct an adapter"
+    factory = zope.interface.Attribute(
+        "Factory to be called to construct an adapter"
         )
 
     def validate(self):
@@ -452,7 +455,7 @@
                 "Cannot have an 'attribute' without a 'factoryName'." %
                 (self.required, self.name))
 
-    def factories(self):
+    def factory(self):
 
         self.validate()
 
@@ -467,7 +470,7 @@
 
 
         if self.attribute:
-            return (AttrViewFactory(class_, self.attribute), )
+            return AttrViewFactory(class_, self.attribute)
 
         else:
 
@@ -479,9 +482,9 @@
             else:
                 template = zapi.traverse(self.__parent__.__parent__,
                                          self.template)
-            return (TemplateViewFactory(class_, template, self.permission), )
+            return TemplateViewFactory(class_, template, self.permission)
 
-    factories = property(factories)
+    factory = property(factory)
 
 
     def addNotify(self, event):




More information about the Zope3-Checkins mailing list