[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser - resourcemeta.py:1.3

Jim Fulton jim@zope.com
Sat, 28 Dec 2002 09:16:15 -0500


Update of /cvs-repository/Zope3/src/zope/app/publisher/browser
In directory cvs.zope.org:/tmp/cvs-serv7527

Modified Files:
	resourcemeta.py 
Log Message:
Untangled view meta configuration from resource meta-configuration in
preparation for refactoring. view no longer subclasses resource.
This allowed us to simplify the resource implementation a bit.



=== Zope3/src/zope/app/publisher/browser/resourcemeta.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/publisher/browser/resourcemeta.py:1.2	Wed Dec 25 09:13:09 2002
+++ Zope3/src/zope/app/publisher/browser/resourcemeta.py	Sat Dec 28 09:16:15 2002
@@ -17,8 +17,7 @@
 """
 
 from zope.security.proxy import Proxy
-from zope.security.checker \
-     import CheckerPublic, NamesChecker, Checker
+from zope.security.checker import CheckerPublic, NamesChecker, Checker
 
 from zope.interfaces.configuration import INonEmptyDirective
 from zope.interfaces.configuration import ISubdirectiveHandler
@@ -37,9 +36,6 @@
     __class_implements__ = INonEmptyDirective
     __implements__ = ISubdirectiveHandler
 
-    type = IBrowserPresentation
-    default_allowed_attributes = '__call__'  # space separated string
-
     def __init__(self, _context, factory=None, name=None, layer='default',
                  permission=None,
                  allowed_interface=None, allowed_attributes=None,
@@ -106,19 +102,14 @@
 
         return [
             Action(
-                discriminator = self._discriminator(name, layer),
+                discriminator = ('resource', name, IBrowserPresentation,
+                                 layer),
                 callable = handler,
-                args = self._args(name, factory, layer),
+                args = ('Resources', 'provideResource',
+                        name, IBrowserPresentation, factory, layer),
                 )
             ]
 
-    def _discriminator(self, name, layer):
-        return ('resource', name, self.type, layer)
-
-    def _args(self, name, factory, layer):
-        return ('Resources', 'provideResource',
-                name, self.type, factory, layer)
-
     def _pageFactory(self, factory, attribute, permission):
         if permission:
             if permission == 'zope.Public':
@@ -156,7 +147,7 @@
 
             if ((not allowed_attributes) and (allowed_interface is None)
                 and (not self.pages)):
-                allowed_attributes = self.default_allowed_attributes
+                allowed_attributes = '__call__'
 
             for name in (allowed_attributes or '').split():
                 require[name] = permission
@@ -173,15 +164,18 @@
 
         return [
             Action(
-                discriminator = self._discriminator(self.name, self.layer),
+                discriminator = ('resource', self.name, IBrowserPresentation,
+                                 self.layer),
                 callable = handler,
-                args = self._args(self.name, factory, self.layer),
+                args = ('Resources', 'provideResource',
+                        self.name, IBrowserPresentation, factory, self.layer),
                 )
             ]
 
     def _proxyFactory(self, factory, checker):
-        def proxyView(request,
-                      factory=factory, checker=checker):
+
+        def proxyResource(request,
+                          factory=factory, checker=checker):
             resource = factory(request)
 
             # We need this in case the resource gets unwrapped and
@@ -190,4 +184,4 @@
 
             return Proxy(resource, checker)
 
-        return proxyView
+        return proxyResource