[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser - metadirectives.py:1.12 viewmeta.py:1.37

Jim Fulton jim at zope.com
Wed Dec 17 10:37:59 EST 2003


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

Modified Files:
	metadirectives.py viewmeta.py 
Log Message:
Now browser:view directives can take a 'provides' attribute to supply
a provided interface. The name attribute can now be ommitted, for
unnamed views.


=== Zope3/src/zope/app/publisher/browser/metadirectives.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/publisher/browser/metadirectives.py:1.11	Sun Dec  7 06:26:11 2003
+++ Zope3/src/zope/app/publisher/browser/metadirectives.py	Wed Dec 17 10:37:27 2003
@@ -40,7 +40,8 @@
     name = TextLine(
         title=u"The name of the view.",
         description=u"The name shows up in URLs/paths. For example 'foo'.",
-        required=True
+        required=False,
+        default=u'',
         )
 
     menu = TextLine(
@@ -61,6 +62,15 @@
           supplied.
           """,
         required=False
+        )
+
+    provides = GlobalObject(
+        title=u"The interface this view provides.",
+        description=u"""
+        A view can provide an interface.  This would be used for
+        views that support other views.""",
+        required=False,
+        default=Interface,
         )
 
 class IViewPageSubdirective(Interface):


=== Zope3/src/zope/app/publisher/browser/viewmeta.py 1.36 => 1.37 ===
--- Zope3/src/zope/app/publisher/browser/viewmeta.py:1.36	Sun Dec  7 06:26:11 2003
+++ Zope3/src/zope/app/publisher/browser/viewmeta.py	Wed Dec 17 10:37:27 2003
@@ -19,7 +19,7 @@
 import os
 
 from zope.app import zapi
-from zope.interface import implements, classImplements
+from zope.interface import implements, classImplements, Interface
 from zope.publisher.interfaces.browser import IBrowserPublisher
 
 from zope.exceptions import NotFoundError
@@ -235,10 +235,10 @@
 
     default = None
 
-    def __init__(self, _context, name, for_, permission,
-                 layer='default', class_=None,
+    def __init__(self, _context, for_, permission,
+                 name='', layer='default', class_=None,
                  allowed_interface=None, allowed_attributes=None,
-                 menu=None, title=None, usage=u''
+                 menu=None, title=None, usage=u'', provides=Interface,
                  ):
 
         _handle_menu(_context, menu, title, for_, name, permission)
@@ -252,6 +252,7 @@
         # default usage is u''
         self.usage = usage
         self.menu = menu
+        self.provides = provides
 
     def page(self, _context, name, attribute=None, template=None, usage=None):
         if template:
@@ -307,6 +308,8 @@
             # XXX This context trickery is a hack around a problem, I
             # can't fix till after the alpha. :(
 
+            # XXX I now wish I could remember what the problem was. :(
+
             def publishTraverse(self, request, name,
                                 pages=pages, getattr=getattr):
 
@@ -362,11 +365,23 @@
 
         defineChecker(newclass, Checker(required))
 
+        if self.provides is not None:
+            _context.action(
+                discriminator = None,
+                callable = handler,
+                args = (Interfaces, 'provideInterface',
+                        self.provides.__module__+'.'+self.provides.__name__,
+                        self.provides)
+                )
+
+
         _context.action(
-            discriminator = ('view', for_, name, IBrowserRequest, layer),
+            discriminator = ('view', for_, name, IBrowserRequest, layer,
+                             self.provides),
             callable = handler,
             args = (zapi.servicenames.Presentation, 'provideView',
-                    for_, name, IBrowserRequest, [newclass], layer),
+                    for_, name, IBrowserRequest, [newclass], layer,
+                    self.provides),
             )
 
 def addview(_context, name, permission,




More information about the Zope3-Checkins mailing list