[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser - globalbrowsermenuservice.py:1.28 meta.zcml:1.16 metaconfigure.py:1.16 metadirectives.py:1.10 viewmeta.py:1.35

Godefroid Chapelle cvs-admin at zope.org
Sun Dec 7 05:05:24 EST 2003


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

Modified Files:
	globalbrowsermenuservice.py meta.zcml metaconfigure.py 
	metadirectives.py viewmeta.py 
Log Message:
merge gotcha-usage-branch

this finishes support for usage :

top-level variable in page templates
initialized from ZCML

main goal is to use a unique template per skin

now, I should walk all templates that relies on dialog_macros.pt
and convert them to template.pt 




=== Zope3/src/zope/app/publisher/browser/globalbrowsermenuservice.py 1.27 => 1.28 ===
--- Zope3/src/zope/app/publisher/browser/globalbrowsermenuservice.py:1.27	Wed Dec  3 00:41:34 2003
+++ Zope3/src/zope/app/publisher/browser/globalbrowsermenuservice.py	Sun Dec  7 05:04:53 2003
@@ -32,6 +32,7 @@
 from zope.app.pagetemplate.engine import Engine
 from zope.app.publication.browser import PublicationTraverser
 from zope.security.proxy import ProxyFactory
+from zope.app import zapi
 
 class Menu:
     """Browser menu"""
@@ -198,6 +199,11 @@
     def menu(self, menu_id, title, description=u'', usage=u''):
         # XXX we have nothing to do with the title and description. ;)
 
+        s = zapi.getService(None, zapi.servicenames.Presentation)
+        if not usage:
+            # usage could be None
+            usage = u''
+        s.useUsage(usage)
         if menu_id in self._registry:
             raise DuplicationError("Menu %s is already defined." % menu_id)
 


=== Zope3/src/zope/app/publisher/browser/meta.zcml 1.15 => 1.16 ===
--- Zope3/src/zope/app/publisher/browser/meta.zcml:1.15	Wed Dec  3 00:40:29 2003
+++ Zope3/src/zope/app/publisher/browser/meta.zcml	Sun Dec  7 05:04:53 2003
@@ -151,6 +151,12 @@
         schema=".metadirectives.IAddMenuItem"
         handler=".metaconfigure.addMenuItem"
         />
+    
+    <meta:directive
+        name="usage"
+        schema=".metadirectives.IUsageDirective"
+        handler=".metaconfigure.usage"
+        />
 
   </meta:directives>
 


=== Zope3/src/zope/app/publisher/browser/metaconfigure.py 1.15 => 1.16 ===
--- Zope3/src/zope/app/publisher/browser/metaconfigure.py:1.15	Wed Dec  3 00:40:29 2003
+++ Zope3/src/zope/app/publisher/browser/metaconfigure.py	Sun Dec  7 05:04:53 2003
@@ -20,7 +20,7 @@
 from zope.publisher.interfaces.browser import IBrowserRequest
 from zope.app.services.servicenames import Interfaces
 
-from zope.app.component.metaconfigure import skin, layer
+from zope.app.component.metaconfigure import skin, layer, usage
 from zope.app.component.metaconfigure import handler
 from zope.app.interfaces.container import IAdding
 from zope.app.publisher.browser.globalbrowsermenuservice \


=== Zope3/src/zope/app/publisher/browser/metadirectives.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/publisher/browser/metadirectives.py:1.9	Wed Dec  3 00:40:29 2003
+++ Zope3/src/zope/app/publisher/browser/metadirectives.py	Sun Dec  7 05:04:53 2003
@@ -23,12 +23,13 @@
 from zope.schema import TextLine, Text, Id
 
 from zope.app.component.metadirectives import IBasicViewInformation
+from zope.app.interfaces.publisher.browser import IUsage
 
 #
 # browser views
 #
 
-class IViewDirective(IBasicViewInformation):
+class IViewDirective(IBasicViewInformation, IUsage):
     """
     The view directive defines a view that has subpages.
 
@@ -199,7 +200,7 @@
         required=False
         )
 
-class IPageDirective(IPagesDirective, IPagesPageSubdirective):
+class IPageDirective(IPagesDirective, IPagesPageSubdirective, IUsage):
     """
     The page directive is used to create views that provide a single
     url or page.
@@ -208,19 +209,6 @@
     and/or class and registers it.
     """
 
-    usage = TextLine(
-        title=u"The template usage top-level variable",
-        description=u"""
-          See the usage documentation in the README.txt in the
-          zope/app/browser/skins directory.
-          If this view is associated with a menu item, this attribute should
-          not be supplied as the view will get its usage from the menu the
-          menu item is registered to.
-          This attribute is available for views not associated with a menu
-          item.
-          """,
-        required=False
-        )
 
 #
 # browser resources
@@ -361,7 +349,7 @@
 # browser menus
 #
 
-class IMenuDirective(Interface):
+class IMenuDirective(IUsage):
     """
     Define a browser menu
     """
@@ -378,16 +366,6 @@
         required=True
         )
 
-    usage = TextLine(
-        title=u"The templates usage top-level variable",
-        description=u"""
-        See the usage documentation in the README.txt in the
-        zope/app/browser/skins directory. If a view is associated with
-        a menu item, the view will get its usage from the menu the
-        menu item is registered to.""",
-        required=False
-        )
-
 class IMenuItemsDirective(Interface):
     """
     Define a group of browser menu items
@@ -479,6 +457,16 @@
     name = TextLine(
         title=u"Name",
         description=u"The name of the skin.",
+        required=True
+        )
+
+class IUsageDirective(Interface):
+    """Defines a view usage
+    """
+
+    name = TextLine(
+        title=u"Name",
+        description=u"The name of the usage.",
         required=True
         )
 


=== Zope3/src/zope/app/publisher/browser/viewmeta.py 1.34 => 1.35 ===
--- Zope3/src/zope/app/publisher/browser/viewmeta.py:1.34	Fri Nov 21 12:10:30 2003
+++ Zope3/src/zope/app/publisher/browser/viewmeta.py	Sun Dec  7 05:04:53 2003
@@ -104,6 +104,11 @@
          usage=u''
          ):
 
+    s = zapi.queryService(None, zapi.servicenames.Presentation)
+    if s is not None:
+        # on startup the service is not immediately there...
+        s.useUsage(usage)
+
     _handle_menu(_context, menu, title, for_, name, permission)
 
     required = {}
@@ -278,6 +283,10 @@
                 # If no usage is declared explicitly for this page, use the
                 # usage given for the whole view.
                 usage = self.usage
+            s = zapi.queryService(None, zapi.servicenames.Presentation)
+            if s is not None:
+                # on startup the service is not immediately there...
+                s.useUsage(usage)
             if template:
                 cdict[pname] = ViewPageTemplateFile(template, usage=usage)
                 if attribute and attribute != name:




More information about the Zope3-Checkins mailing list