[Zope3-checkins] CVS: Zope3/src/zope/app/services - configure.zcml:1.10 view.py:1.4

Jim Fulton jim@zope.com
Tue, 21 Jan 2003 16:45:40 -0500


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

Modified Files:
	configure.zcml view.py 
Log Message:
Added permission to the schema for TTW view and page configurations.
Updated pages to use the permisssion.

Changed TTW views and pages to use "class" rather than "factory",
where a class is just a mix-in class. It need not provide a standard
__init__ or mix in BrowserView.

Made it possible to change the class.

Removed the presentation type from page configurations. The
persentation type is always IBrowserPresentation.



=== Zope3/src/zope/app/services/configure.zcml 1.9 => 1.10 ===
--- Zope3/src/zope/app/services/configure.zcml:1.9	Fri Jan 17 09:02:09 2003
+++ Zope3/src/zope/app/services/configure.zcml	Tue Jan 21 16:45:07 2003
@@ -71,7 +71,7 @@
   <require
       permission="zope.ManageServices"
       interface="zope.app.interfaces.services.interfaces.IPageConfiguration"
-      set_schema="zope.app.interfaces.services.configuration.IConfiguration"
+      set_schema="zope.app.interfaces.services.interfaces.IPageConfiguration"
       />
   <require
       permission="zope.ManageServices"


=== Zope3/src/zope/app/services/view.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/services/view.py:1.3	Thu Jan 16 07:00:00 2003
+++ Zope3/src/zope/app/services/view.py	Tue Jan 21 16:45:07 2003
@@ -20,6 +20,9 @@
 
 from persistence import Persistent
 from persistence.dict import PersistentDict
+
+from zope.publisher.interfaces.browser import IBrowserPresentation
+
 from zope.component.interfaces import IViewService
 from zope.component.exceptions import ComponentLookupError
 from zope.component import getServiceManager
@@ -32,6 +35,8 @@
 from zope.app.component.nextservice import getNextService
 from zope.component import getSkin
 
+from zope.security.checker import NamesChecker, ProxyFactory
+
 from zope.proxy.introspection import removeAllProxies
 from zope.app.traversing import getPhysicalRoot, traverse
 from zope.exceptions import NotFoundError
@@ -216,16 +221,17 @@
 
     def __init__(self,
                  forInterface, viewName, presentationType,
-                 factoryName, layer='default'):
+                 class_, permission, layer='default'):
         self.forInterface = forInterface
         self.presentationType = presentationType
-        self.factoryName = factoryName
+        self.class_ = class_
         self.viewName = viewName
         self.layer = layer
+        self.permission = permission
 
     def getView(self, object, request):
         sm = getServiceManager(self)
-        factory = sm.resolve(self.factoryName)
+        factory = sm.resolve(self.class_)
         return factory(object, request)
 
     getView = ContextMethod(getView)
@@ -234,37 +240,46 @@
 
     __implements__ = IPageConfiguration, ViewConfiguration.__implements__
 
+    # We only care about browser pages
+    presentationType = IBrowserPresentation
+
     def __init__(self,
-                 forInterface, viewName, presentationType,
-                 factoryName=None, template=None,
+                 forInterface, viewName, permission,                 
+                 class_=None, template=None,
                  layer='default'):
+
+        
         super(PageConfiguration, self).__init__(
-            forInterface, viewName, presentationType,
-            factoryName, layer)
+            forInterface, viewName, self.presentationType,
+            class_, permission, layer)
 
         self.template = template
 
     def getView(self, object, request):
         sm = getServiceManager(self)
 
-        if self.factoryName:
-            factory = sm.resolve(self.factoryName)
+        if self.class_:
+            class_ = sm.resolve(self.class_)
+            class_ = type(class_.__name__, (class_, DefaultClass), {})
+            
         else:
-            factory = DefaultFactory
+            class_  = DefaultClass
 
-        view = factory(object, request)
+        view = class_(object, request)
 
         # This is needed because we need to do an unrestricted traverse
         root = removeAllProxies(getPhysicalRoot(sm))
 
         template = traverse(root, self.template)
 
-        return BoundTemplate(template, view)
+        checker = NamesChecker(__call__ = self.permission)
+
+        return ProxyFactory(BoundTemplate(template, view), checker)
 
     getView = ContextMethod(getView)
 
 
-class DefaultFactory:
+class DefaultClass:
 
     def __init__(self, context, request):
         self.context = context