[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser - resourcedirectorymeta.py:1.1 globalbrowsermenuservice.py:1.21 i18nresourcemeta.py:1.13 icon.py:1.10 meta.zcml:1.12 metaconfigure.py:1.11 resourcemeta.py:1.10 viewmeta.py:1.30

Philipp von Weitershausen philikon at philikon.de
Sat Aug 2 23:13:56 EDT 2003


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

Modified Files:
	globalbrowsermenuservice.py i18nresourcemeta.py icon.py 
	meta.zcml metaconfigure.py resourcemeta.py viewmeta.py 
Added Files:
	resourcedirectorymeta.py 
Log Message:
Here we go again. All tests have been run twice and passed. Sorry again for
the trouble I've caused. Anthony and Steve, I owe you guys are beer.

Converted the three most important packages that define ZCML directives
to the new ZCML architecture (using schemas):

- zope.app.component

- zope.app.browser.form

- zope.app.publisher.browser


=== Added File Zope3/src/zope/app/publisher/browser/resourcedirectorymeta.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Browser configuration code

$Id: resourcedirectorymeta.py,v 1.1 2003/08/03 02:13:17 philikon Exp $
"""

from zope.interface import Interface
from zope.configuration.fields import GlobalObject
from zope.schema import TextLine

class IResourceDirectoryDirective(Interface):

    pass


=== Zope3/src/zope/app/publisher/browser/globalbrowsermenuservice.py 1.20 => 1.21 ===
--- Zope3/src/zope/app/publisher/browser/globalbrowsermenuservice.py:1.20	Sat Aug  2 05:11:21 2003
+++ Zope3/src/zope/app/publisher/browser/globalbrowsermenuservice.py	Sat Aug  2 22:13:17 2003
@@ -15,8 +15,6 @@
 from zope.interface import classProvides
 from zope.exceptions import DuplicationError, Unauthorized, Forbidden
 
-from zope.configuration.action import Action
-
 from zope.interface.type import TypeRegistry
 from zope.interface import implements
 
@@ -27,7 +25,7 @@
 
 from zope.app.security.permission import checkPermission
 
-from zope.app.component.metaconfigure import handler, resolveInterface
+from zope.app.component.metaconfigure import handler
 from zope.app.interfaces.publisher.browser import IBrowserMenuService
 from zope.app.pagetemplate.engine import Engine
 from zope.app.publication.browser import PublicationTraverser
@@ -175,11 +173,11 @@
         return None
 
 def menuDirective(_context, id, title, description='', usage=u''):
-    return [Action(
+    _context.action(
         discriminator = ('browser:menu', id),
         callable = globalBrowserMenuService.menu,
         args = (id, title, description, usage),
-        )]
+        )
 
 def menuItemDirective(_context, menu, for_,
                       action, title, description='', filter=None,
@@ -191,36 +189,27 @@
 class menuItemsDirective:
 
     def __init__(self, _context, menu, for_):
-        if for_ == '*':
-            self.interface = None
-        else:
-            self.interface = resolveInterface(_context, for_)
+        self.interface = for_
         self.menu = menu
 
     def menuItem(self, _context, action, title, description='',
                  filter=None, permission=None):
-
-        return [
-            Action(
-              discriminator = ('browser:menuItem',
-                               self.menu, self.interface, title),
-              callable = globalBrowserMenuService.menuItem,
-              args = (self.menu, self.interface,
-                      action, title, description, filter, permission),
-              ),
-                ]
-
-    def __call__(self):
-        return [
-            Action(
-              discriminator = None,
-              callable = handler,
-              args = (Interfaces, 'provideInterface',
-                      self.interface.__module__+'.'+self.interface.__name__,
-                      self.interface)
-              )
-            ]
-
+        _context.action(
+            discriminator = ('browser:menuItem',
+                             self.menu, self.interface, title),
+            callable = globalBrowserMenuService.menuItem,
+            args = (self.menu, self.interface,
+                    action, title, description, filter, permission),
+            ),
+
+    def __call__(self, _context):
+        _context.action(
+            discriminator = None,
+            callable = handler,
+            args = (Interfaces, 'provideInterface',
+                    self.interface.__module__+'.'+self.interface.__name__,
+                    self.interface)
+            )
 
 globalBrowserMenuService = GlobalBrowserMenuService()
 


=== Zope3/src/zope/app/publisher/browser/i18nresourcemeta.py 1.12 => 1.13 ===
--- Zope3/src/zope/app/publisher/browser/i18nresourcemeta.py:1.12	Sat Aug  2 05:11:21 2003
+++ Zope3/src/zope/app/publisher/browser/i18nresourcemeta.py	Sat Aug  2 22:13:17 2003
@@ -20,17 +20,13 @@
 from zope.security.proxy import Proxy
 from zope.security.checker import CheckerPublic, Checker
 
-from zope.configuration.action import Action
 from zope.configuration.exceptions import ConfigurationError
-
 from zope.app.services.servicenames import Resources
-
 from zope.publisher.interfaces.browser import IBrowserPresentation
-
 from zope.app.component.metaconfigure import handler
 
 from zope.app.publisher.fileresource import File, Image
-from zope.app.publisher.browser.i18nfileresource import I18nFileResourceFactory
+from i18nfileresource import I18nFileResourceFactory
 
 class I18nResource(object):
 
@@ -39,6 +35,7 @@
 
     def __init__(self, _context, name=None, defaultLanguage='en',
                  layer='default', permission=None):
+        self._context = _context
         self.name = name
         self.defaultLanguage = defaultLanguage
         self.layer = layer
@@ -46,7 +43,6 @@
         self.__data = {}
         self.__format = None
 
-
     def translation(self, _context, language, file=None, image=None):
 
         if file is not None and image is not None:
@@ -104,15 +100,12 @@
 
             factory = self._proxyFactory(factory, checker)
 
-        return [
-            Action(
-                discriminator = ('i18n-resource', self.name, self.type,
-                                 self.layer),
-                callable = handler,
-                args = (Resources, 'provideResource', self.name, self.type,
-                        factory, self.layer)
-                )
-            ]
+        self._context.action(
+            discriminator = ('i18n-resource', self.name, self.type, self.layer),
+            callable = handler,
+            args = (Resources, 'provideResource', self.name, self.type,
+                    factory, self.layer)
+            )
 
 
     def _proxyFactory(self, factory, checker):


=== Zope3/src/zope/app/publisher/browser/icon.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/publisher/browser/icon.py:1.9	Sat Aug  2 05:11:21 2003
+++ Zope3/src/zope/app/publisher/browser/icon.py	Sat Aug  2 22:13:17 2003
@@ -20,8 +20,7 @@
 import os
 import re
 
-from zope.app.component.metaconfigure import handler, resolveInterface
-from zope.configuration.action import Action
+from zope.app.component.metaconfigure import handler
 from zope.app.publisher.browser import metaconfigure
 from zope.app.traversing.namespace import getResourceInContext
 from zope.publisher.interfaces.browser import IBrowserPresentation
@@ -64,7 +63,6 @@
 def IconDirective(_context, name, for_, file=None, resource=None,
                   layer='default', alt=None):
 
-    for_ = resolveInterface(_context, for_)
     iname = for_.__name__
 
     if alt is None:
@@ -72,7 +70,6 @@
         if IName.match(alt):
             alt = alt[1:] # Remove leading 'I'
 
-    results = []
     if file is not None and resource is not None:
         raise ConfigurationError(
             "Can't use more than one of file, and resource "
@@ -84,8 +81,8 @@
         ext = os.path.splitext(file)[1]
         if ext:
             resource += ext
-        results = metaconfigure.resource(_context, image=file,
-                                         name=resource, layer=layer)
+        metaconfigure.resource(_context, image=file,
+                               name=resource, layer=layer)
     elif resource is None:
         raise ConfigurationError(
             "At least one of the file, and resource "
@@ -94,18 +91,17 @@
 
     vfactory = IconViewFactory(resource, alt)
 
-    return results + [
-        Action(
+    _context.action(
         discriminator = ('view', name, vfactory, layer),
         callable = handler,
         args = ('Views', 'provideView',
                 for_, name, IBrowserPresentation,
-                vfactory, layer)),
-        Action(
+                vfactory, layer)
+        )
+    _context.action(
         discriminator = None,
         callable = handler,
         args = (Interfaces, 'provideInterface',
                 for_.__module__+'.'+for_.__name__,
                 for_)
         )
-        ]


=== Zope3/src/zope/app/publisher/browser/meta.zcml 1.11 => 1.12 ===
--- Zope3/src/zope/app/publisher/browser/meta.zcml:1.11	Sat Aug  2 05:11:21 2003
+++ Zope3/src/zope/app/publisher/browser/meta.zcml	Sat Aug  2 22:13:17 2003
@@ -1,847 +1,139 @@
-<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
-  
-  <directives namespace="http://namespaces.zope.org/browser">
-
-    <directive name="page" handler=".viewmeta.page">
-
-      <description>
-        The page directive is used to create views that provide a
-        single url or page.
-
-        The page directive creates a new view class from a given
-        template and/or class and registers it.
-      </description>
-
-
-      <attribute name="name" required="yes">
-        <description>
-              The name of the page (view).
- 
-              The name shows up in URLs/paths. For example 'foo' or 
-              'foo.html'. This attribute is required unless you use the
-              subdirective 'page' to create sub views. If you do not have
-              sub pages, it is common to use an extension for the view name 
-              such as '.html'. If you do have sub pages and you want to
-              provide a view name, you shouldn't use
-              extensions. 
-          </description>
-       </attribute>
-
-      <attribute name="for" required="yes">
-        <description>
-              The interface this page (view) applies to. 
-
-              The view will be for all objects that implement this interface.
-
-              To provide a page for all components, use
-              "zope.interface.Interface".  To provide a page for all
-              objects, use "*".
-          </description>
-      </attribute>
-
-      <attribute name="permission" required="yes">
-        <description>
-              The permission needed to use the view. 
-          </description>
-      </attribute>
-
-      <attribute name="template">
-        <description>
-          The name of a page template.
-
-          Refers to a file containing a page template (must end in
-          extension '.pt').
-          </description>
-      </attribute>
-
-      <attribute name="attribute" required="no">
-        <description>
-           The name of an attribute to publish.
-
-           This is used to publish an attribute provided by a class,
-           instead of a template.
-
-           This is the attribute, usually a method, to be published as
-           the page (view).  The default is "__call__".
-          </description>
-      </attribute>
-
-      <attribute name="class">
-        <description>
-           A class to use with a template, or to provide an attribute
-           to publish.
-
-           It's common to provide a class with methods to be used by
-           the template to prevent including Python code in the template.
-          </description>
-      </attribute>
-
-      <attribute name="layer" required="no">
-        <description>
-              The layer the view is in. 
-
-              A skin is composed of layers. It is common to put skin specific
-              views in a layer named after the skin. If the 'layer' attribute
-              is not supplied, it defaults to
-              'default'. 
-          </description>
-      </attribute>
-
-      <attribute name="allowed_interface" required="no">
-        <description>
-              Interface that is also allowed if user has permission.
-
-              By default, 'permission' only applies to viewing the view and 
-              any possible sub views. By specifying this attribute, you can
-              make the permission also apply to everything described in the 
-              supplied interface. 
-
-              Multiple interfaces, separated by whitespace, can be provided.
-          </description>
-      </attribute>
-
-      <attribute name="allowed_attributes" required="no">
-        <description>
-              View attributes that are also allowed if user has permission.
-
-              By default, 'permission' only applies to viewing the view and any
-              possible sub views. By specifying 'allowed_attributes', you can
-              make the permission also apply to the extra attributes on the 
-              view object. 
-          </description>
-      </attribute>
-
-      <attribute name="menu" required="no">
-        <description>
-          The browser menu to include the page (view) in.
-
-          Many views are included in menus. It's convenient to name
-          the menu in the page directive, rather than having to give a
-          separate menuItem directive.          
-          </description>
-      </attribute>
-
-      <attribute name="title" required="no">
-        <description>
-          The browser menu label for the page (view)
-
-          This attribute must be supplied if a menu attribute is
-          supplied. 
-          </description>
-      </attribute>
-
-      <attribute name="usage" required="no">
-        <description>
-          The template usage top-level variable
-
-          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.
-        </description>
-      </attribute>
-
-    </directive>
-
-    <directive name="pages" handler=".viewmeta.pages">
-
-      <description>
-        Define multiple pages without repeating all of the parameters.
-
-        The pages directive allows multiple page views to be defined
-        without repeating the 'for', 'permission', 'class', 'layer',
-        'allowed_attributes', and 'allowed_interface' attributes.
-      </description>
-
-      <attribute name="for" required="yes">
-        <description>
-              The interface this page (view) applies to. 
-
-              The view will be for all objects that implement this interface.
-
-              To provide a page for all components, use
-              "zope.interface.Interface".  To provide a page for all
-              objects, use "*".
-          </description>
-      </attribute>
-
-      <attribute name="permission" required="yes">
-        <description>
-              The permission needed to use the view. 
-          </description>
-      </attribute>
-
-      <attribute name="class">
-        <description>
-           A class to use with a template, or to provide an attribute
-           to publish.
-
-           It's common to provide a class with methods to be used by
-           the template to prevent including Python code in the template.
-          </description>
-      </attribute>
-
-      <attribute name="layer" required="no">
-        <description>
-              The layer the view is in. 
-
-              A skin is composed of layers. It is common to put skin specific
-              views in a layer named after the skin. If the 'layer' attribute
-              is not supplied, it defaults to
-              'default'. 
-          </description>
-      </attribute>
-
-      <attribute name="allowed_interface" required="no">
-        <description>
-              Interface that is also allowed if user has permission.
-
-              By default, 'permission' only applies to viewing the view and 
-              any possible sub views. By specifying this attribute, you can
-              make the permission also apply to everything described in the 
-              supplied interface. 
-          </description>
-      </attribute>
-
-      <attribute name="allowed_attributes" required="no">
-        <description>
-              View attributes that are also allowed if user has permission.
-
-              By default, 'permission' only applies to viewing the view and any
-              possible sub views. By specifying 'allowed_attributes', you can
-              make the permission also apply to the extra attributes on the 
-              view object. 
-          </description>
-      </attribute>
-
-      <subdirective name="page">
-
-        <attribute name="name" required="yes">
-          <description>
-                The name of the view defined by the page. 
-
-                The name shows up in URLs/paths. For example 'foo' or 
-                'foo.html'. This attribute is required unless you use the
-                subdirective 'page' to create sub views. If you do not have
-                sub pages, it is common to use an extension for the view name 
-                such as '.html'. If you do have sub pages and you want to
-                provide a view name, you shouldn't use
-                extensions. 
-            </description>
-         </attribute>
-
-        <attribute name="template">
-          <description>
-                The name of a page template.
-
-                Refers to a file containing a page template (must end in
-                extension '.pt').
-          </description>
-        </attribute>
-
-        <attribute name="attribute" required="no">
-          <description>
-             If a class is used, this is the name of the attribute to be used
-
-             This is the attribute, usually a method, to be published as
-             the page (view).  The fault is "__call__".
-            </description>
-        </attribute>
-
-        <attribute name="menu" required="no">
-          <description>
-            The browser menu to include the page (view) in.
-
-            Many views are included in menus. It's convenient to name
-            the menu in the page directive, rather than having to give a
-            separate menuItem directive.          
-            </description>
-        </attribute>
-
-        <attribute name="title" required="no">
-          <description>
-            The browser menu label for the page (view)
-
-            This attribute must be supplied if a menu attribute is
-            supplied. 
-            </description>
-        </attribute>
-
-      </subdirective>
-
-    </directive>
-
-    <directive name="view" handler=".viewmeta.view">
-
-      <description>
-        The view directive defines a view that has subpages.
-
-        The pages provided by the defined view are accessed by first
-        traversing to the view name and then traversing to the page
-        name. 
-      </description>
-
-      <attribute name="name" required="yes">
-
-        <description>
-              The name of the view. 
- 
-              The name shows up in URLs/paths. For example 'foo'. 
-          </description>
-       </attribute>
-
-       <attribute name="for" required="yes">
-        <description>
-              The interface this view applies to. 
-
-              The view will be for all objects that implement this interface.
-              If 'for' is not supplied, the view applies to all objects 
-              (XXX this ought to change). 
-          </description>
-      </attribute>
-
-      <attribute name="class" required="no">
-        <description>
-              A class that provides attributes used by the view. 
-          </description>
-      </attribute>
-
-       <attribute name="permission" required="yes">
-        <description>
-              The permission needed to use the view. 
-          </description>
-      </attribute>
-
-      <attribute name="layer" required="no">
-        <description>
-              The layer the view is in. 
-
-              A skin is composed of layers. It is common to put skin specific
-              views in a layer named after the skin. If the 'layer' attribute
-              is not supplied, it defaults to
-              'default'. 
-          </description>
-      </attribute>
-
-      <attribute name="allowed_interface" required="no">
-        <description>
-              Interface that is also allowed if user has permission.
-
-              By default, 'permission' only applies to viewing the view and 
-              any possible sub views. By specifying this attribute, you can
-              make the permission also apply to everything described in the 
-              supplied interface. 
-
-              Multiple interfaces can be provided, separated by whitespace.
-          </description>
-      </attribute>
-
-      <attribute name="allowed_attributes" required="no">
-        <description>
-              View attributes that are also allowed if user has permission.
-
-              By default, 'permission' only applies to viewing the view and any
-              possible sub views. By specifying 'allowed_attributes', you can
-              make the permission also apply to the extra attributes on the 
-              view object. 
-          </description>
-      </attribute>
-
-      <attribute name="menu" required="no">
-        <description>
-          The browser menu to include the page (view) in.
-
-          Many views are included in menus. It's convenient to name
-          the menu in the page directive, rather than having to give a
-          separate menuItem directive.          
-          </description>
-      </attribute>
-
-      <attribute name="title" required="no">
-        <description>
-          The browser menu label for the page (view)
-
-          This attribute must be supplied if a menu attribute is
-          supplied. 
-          </description>
-      </attribute>
-
-      <subdirective name="page">
-
-         <attribute name="name" required="yes">
-           <description>
-                 The name of a sub page of a view.
-
-                 The name attribute is always required for the 'page'
-                 directive. It is common to use an extension for the name, 
-                 such as '.html'. 
-           </description>
-         </attribute>
-
-         <attribute name="attribute">
-           <description>
-                 The name of the view attribute implementing the page.
-
-                 This refers to the attribute (method) on the view that is 
-                 implementing a specific sub page. 
-           </description>
-         </attribute>
-
-         <attribute name="template">
-           <description>
-              The name of a template that implements the page.
-           </description>
-         </attribute>
-
-       </subdirective>
-
-       <subdirective name="defaultPage">
-
-         <attribute name="name" required="yes">
-           <description>
-                 The name of the page that is the default.
-
-                 The named page will be used as the default if no name is
-                 specified explicitly in the path. If no defaultPage 
-                 directive is supplied, the default page will be the
-                 first page listed. 
-             </description>
-         </attribute>
-
-       </subdirective>
-      </directive>
-
-    <directive name="addview" handler=".viewmeta.addview">
-
-      <description>
-        The addview directive defines an add view that has subpages.
-
-        An add view is a view for a specific adding interface,
-        IAdding. This directive is a convenience directive that allows
-        the for interface to be omitted, since it is implied.
-
-        The pages provided by the defined view are accessed by first
-        traversing to the view name and then traversing to the page
-        name. 
-      </description>
-
-      <attribute name="name" required="yes">
-
-        <description>
-              The name of the view. 
- 
-              The name shows up in URLs/paths. For example 'foo'. 
-          </description>
-       </attribute>
-
-       <attribute name="for" required="yes">
-        <description>
-              The interface this view applies to. 
-
-              The view will be for all objects that implement this interface.
-              If 'for' is not supplied, the view applies to all objects 
-              (XXX this ought to change). 
-          </description>
-      </attribute>
-
-      <attribute name="class" required="no">
-        <description>
-              A class that provides attributes used by the view. 
-          </description>
-      </attribute>
-
-       <attribute name="permission" required="yes">
-        <description>
-              The permission needed to use the view. 
-          </description>
-      </attribute>
-
-      <attribute name="layer" required="no">
-        <description>
-              The layer the view is in. 
-
-              A skin is composed of layers. It is common to put skin specific
-              views in a layer named after the skin. If the 'layer' attribute
-              is not supplied, it defaults to
-              'default'. 
-          </description>
-      </attribute>
-
-      <attribute name="allowed_interface" required="no">
-        <description>
-              Interface that is also allowed if user has permission.
-
-              By default, 'permission' only applies to viewing the view and 
-              any possible sub views. By specifying this attribute, you can
-              make the permission also apply to everything described in the 
-              supplied interface. 
-
-              Multiple interfaces can be provided, separated by whitespace.
-          </description>
-      </attribute>
-
-      <attribute name="allowed_attributes" required="no">
-        <description>
-              View attributes that are also allowed if user has permission.
-
-              By default, 'permission' only applies to viewing the view and any
-              possible sub views. By specifying 'allowed_attributes', you can
-              make the permission also apply to the extra attributes on the 
-              view object. 
-          </description>
-      </attribute>
-
-      <attribute name="menu" required="no">
-        <description>
-          The browser menu to include the page (view) in.
-
-          Many views are included in menus. It's convenient to name
-          the menu in the page directive, rather than having to give a
-          separate menuItem directive.          
-          </description>
-      </attribute>
-
-      <attribute name="title" required="no">
-        <description>
-          The browser menu label for the page (view)
-
-          This attribute must be supplied if a menu attribute is
-          supplied. 
-          </description>
-      </attribute>
-
-      <subdirective name="page">
-
-         <attribute name="name" required="yes">
-           <description>
-                 The name of a sub page of a view.
-
-                 The name attribute is always required for the 'page'
-                 directive. It is common to use an extension for the name, 
-                 such as '.html'. 
-           </description>
-         </attribute>
-
-         <attribute name="attribute">
-           <description>
-                 The name of the view attribute implementing the page.
-
-                 This refers to the attribute (method) on the view that is 
-                 implementing a specific sub page. 
-           </description>
-         </attribute>
-
-         <attribute name="template">
-           <description>
-              The name of a template that implements the page.
-           </description>
-         </attribute>
-
-       </subdirective>
-
-       <subdirective name="defaultPage">
-
-         <attribute name="name" required="yes">
-           <description>
-                 The name of the page that is the default.
-
-                 The named page will be used as the default if no name is
-                 specified explicitly in the path. If no defaultPage 
-                 directive is supplied, the default page will be the
-                 first page listed. 
-             </description>
-         </attribute>
-
-       </subdirective>
-      </directive>
-
-    <directive name="defaultView" 
-               handler="zope.app.publisher.browser.metaconfigure.defaultView"
-               >
-      <attribute name="name" >
-        <description>
-              The name of the view that should be the default.
-              
-              This name refers to view that should be the
-              view used by default (if no view name is supplied
-              explicitly). 
-          </description>
-      </attribute>
-
-      <attribute name="for">
-        <description>
-              The interface this view is the default for.
-
-              The view is the default view for the supplied
-              interface. 
-          </description>
-      </attribute>
-
-    </directive>
-
-    <directive name="resource"
-        handler="zope.app.publisher.browser.metaconfigure.resource"
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:meta="http://namespaces.zope.org/meta">
+
+  <meta:directives namespace="http://namespaces.zope.org/browser">
+
+    <!-- browser views -->
+
+    <meta:complexDirective
+        name="view"
+        schema=".metadirectives.IViewDirective"
+        handler=".viewmeta.view"
         >
 
-      <attribute name="name" required="yes">
-
-         <description>
-           The name of the resource
-
-           This is the name used in resource urls.  Resource urls are
-           of the form site/@@/resourcename, where site is the url of
-           "site", a folder with a service manager.
-
-           We make resource urls site-relative (as opposed to
-           content-relative) so as not to defeat caches.
-         </description>
-
-       </attribute>
-
-       <attribute name="layer" required="no">
-
-         <description>
-           The layer the resource should be found in
-
-           For information on layers, see the documentation for the
-           skin directive.
-
-           Defaults to "default".
-         </description>
-
-       </attribute>
+      <meta:subdirective
+          name="page"
+          schema=".metadirectives.IViewPageSubdirective"
+          />
 
-       <attribute name="file">
+      <meta:subdirective
+          name="defaultPage"
+          schema=".metadirectives.IViewDefaultPageSubdirective"
+          />
 
-         <description>
-            The file containing the resource data.
-         </description>
+    </meta:complexDirective>
 
-       </attribute>
+    <meta:complexDirective
+        name="addview"
+        schema=".metadirectives.IViewDirective"
+        handler=".viewmeta.addview"
+        >
 
-       <attribute name="image">
+      <meta:subdirective
+          name="page"
+          schema=".metadirectives.IViewPageSubdirective"
+          />
 
-         <description>
-            The file containing the resource data.
+      <meta:subdirective
+          name="defaultPage"
+          schema=".metadirectives.IViewDefaultPageSubdirective"
+          />
 
-            If the image attribute is used, then an image resource,
-            rather than a file resource will be created.
-         </description>
+    </meta:complexDirective>
 
-       </attribute>
+    <meta:directive
+        name="defaultView"
+        schema=".metadirectives.IDefaultViewDirective"
+        handler=".metaconfigure.defaultView"
+        />
+
+
+    <!-- browser pages -->
+
+    <meta:directive
+        name="page"
+        schema=".metadirectives.IPageDirective"
+        handler=".viewmeta.page"
+        />
+
+    <meta:complexDirective
+        name="pages"
+        schema=".metadirectives.IPagesDirective"
+        handler=".viewmeta.pages"
+        >
 
-       <attribute name="permission" required="no">
+      <meta:subdirective
+          name="page"
+          schema=".metadirectives.IPagesPageSubdirective"
+          />
 
-         <description>
-           The id of the permission needed to access the resource.
+    </meta:complexDirective>
 
-           If a permission isn't specified, the resource will always
-           be accessible.
-         </description>
 
-       </attribute>
+    <!-- browser resources -->
 
-       </directive>
+    <meta:directive
+        name="resource"
+        schema=".metadirectives.IResourceDirective"
+        handler=".metaconfigure.resource"
+        />
 
-    <directive
+    <meta:complexDirective
         name="i18n-resource"
-        attributes="name defaultLanguage"
-        handler="zope.app.publisher.browser.metaconfigure.I18nResource">
-      <attribute
-          name="name" />
-      <attribute
-          name="default_language" />
-      <subdirective name="translation">
-        <attribute
-            name="language" />
-        <attribute
-            name="file" />
-        <attribute
-            name="image" />
-      </subdirective>
-      </directive>
-
-    <directive name="skin"
-        handler="zope.app.publisher.browser.metaconfigure.skin"
-        >
-
-      <attribute
-          name="name"
-          description="The name of the skin." />
-      <attribute name="layers">
-        <description>
-              A list of names of layers. 
-
-              This should be in order of lookup. Usually one of the layers
-              has the same name as the skin, and the last skin should be
-              'default', unless you want to completely override all
-              views.
-          </description>
-      </attribute>
-
-      </directive>
-
-    <directive name="menu"
-        handler="
-            zope.app.publisher.browser.globalbrowsermenuservice.menuDirective"
-        description="Define a new browser menu"
+        schema=".metadirectives.II18nResourceDirective"
+        handler=".metaconfigure.I18nResource"
         >
 
-      <attribute name="id">
-        <description>
-              The name of the menu.
-
-              This is, effectively, an id.     
-        </description>
-      </attribute>
-
-
-      <attribute
-          name="title"
-          description="A descriptive title for documentation purposes"
+      <meta:subdirective
+          name="translation"
+          schema=".metadirectives.II18nResourceTranslationSubdirective"
           />
 
-      <attribute name="usage">
-        <description>
-          The templates usage top-level variable
-
-          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.
-        </description>
-      </attribute>
+    </meta:complexDirective>
+
 
-    </directive>
+    <!-- browser menus -->
 
+    <meta:directive
+        name="menu"
+        schema=".metadirectives.IMenuDirective"
+        handler=".globalbrowsermenuservice.menuDirective"
+        />
 
-    
-    <directive
+    <meta:complexDirective
         name="menuItems"
-        attributes="menu for" 
-        handler="
-        zope.app.publisher.browser.globalbrowsermenuservice.menuItemsDirective"
+        schema=".metadirectives.IMenuItemsDirective"
+        handler=".globalbrowsermenuservice.menuItemsDirective"
         >
-      <description>
-        Define a group of browser menu items
 
-        This directive is useful when many menu items are defined for
-        the same interface and menu.
-      </description>
-
-      <attribute
-          name="menu"
-          required="yes"
-          description="The (name of the) menu the items are defined for"
+      <meta:subdirective
+          name="menuItem"
+          schema=".metadirectives.IMenuItemSubdirective"
           />
 
-      <attribute
-          name="for"
-          required="no"
-          description="The interface the menu items are defined for"
-          />
-
-      <subdirective
-          name="menuItem" 
-          description="Define a menu item within a group of menu items"
-          >
-
-        <attribute name="action" required="yes">
-          <description>
-          The relative url to use if the item is selected
-
-          The url is relative to the object the menu is being
-          displayed for.
-          </description>
-      </attribute>
-
-        <attribute
-            name="title" 
-            required="yes"
-            description="The text to be displayed for the menu item" 
-            />
-
-        <attribute name="description">
-          <description>
-          A longer explanation of the menu item
-
-          A UI may display this with the item or display it when the
-          user requests more assistance.
-          </description>
-      </attribute>
-
-        <attribute name="permission" required="no">
-          <description>
-            The id of the permission needed access the item
-
-            This can usually be inferred by the system, however, doing
-            so may be expensive. When displaying a menu, the system
-            tries to traverse to the URLs given in each action to
-            determine whether the url is accessible to the current
-            user.  This can be avoided if the permission is given explicitly. 
-          </description>
-      </attribute>
-
-        <attribute name="filter" required="no"> 
-          <description>
-            A condition for displaying the menu item
-
-            The condition is given as a TALES expression. The
-            expression has access to the variables:
-
-            context -- The object the menu is being displayed for
-
-            request -- The browser request
-
-            nothing -- None
-
-            The menu item will not be displayed if there is a filter
-            and the filter evaluates to a false value.
-          </description>
-      </attribute>
-     </subdirective> 
-    </directive>
-
-    <directive name="menuItem" 
-        handler="
-        zope.app.publisher.browser.globalbrowsermenuservice.menuItemDirective"
-        >
+    </meta:complexDirective>
 
-      <attribute
-          name="menu" />
-      <attribute
-          name="for" />
-      <attribute
-          name="action" />
-      <attribute
-          name="title" />
-      <attribute
-          name="description" />
-      <attribute
-          name="filter" />
-      <attribute
-          name="permission" />
-      </directive>
-
-    <directive name="icon" handler=".icon.IconDirective">
-
-      <attribute
-          name="name" />
-      <attribute
-          name="for" />
-      <attribute
-          name="file" />
-      <attribute
-          name="resource" />
-      <attribute
-          name="alt" />
-      <attribute
-          name="layer" />
-    </directive>
+    <meta:directive
+        name="menuItem"
+        schema=".metadirectives.IMenuItemDirective"
+        handler=".globalbrowsermenuservice.menuItemDirective"
+        />
+
+    <!-- misc. directives -->
+
+    <meta:directive
+        name="skin"
+        schema=".metadirectives.ISkinDirective"
+        handler=".metaconfigure.skin"
+        />
+
+    <meta:directive
+        name="icon"
+        schema=".metadirectives.IIconDirective"
+        handler=".icon.IconDirective"
+        />
 
-  </directives>
+  </meta:directives>
 
-</zopeConfigure>
+</configure>


=== Zope3/src/zope/app/publisher/browser/metaconfigure.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/publisher/browser/metaconfigure.py:1.10	Sat Aug  2 05:11:21 2003
+++ Zope3/src/zope/app/publisher/browser/metaconfigure.py	Sat Aug  2 22:13:17 2003
@@ -16,13 +16,11 @@
 $Id$
 """
 
-from zope.configuration.action import Action
-
 from zope.publisher.interfaces.browser import IBrowserPresentation
 from zope.app.services.servicenames import Interfaces
 
 from zope.app.component.metaconfigure import skin as _skin
-from zope.app.component.metaconfigure import handler, resolveInterface
+from zope.app.component.metaconfigure import handler
 
 # referred to through ZCML
 from zope.app.publisher.browser.resourcemeta import resource
@@ -31,40 +29,26 @@
 from zope.app.publisher.browser.viewmeta import view
 
 def skin(_context, **__kw):
-    return _skin(_context,
-                 type='zope.publisher.interfaces.browser.IBrowserPresentation',
-                 **__kw)
+    return _skin(_context, type=IBrowserPresentation, **__kw)
 
 def defaultView(_context, name, for_=None, **__kw):
 
     if __kw:
-        actions = view(_context, name=name, for_=for_, **__kw)()
-    else:
-        actions = []
-
-    if for_ is not None:
-        for_ = resolveInterface(_context, for_)
+        view(_context, name=name, for_=for_, **__kw)()
 
     type = IBrowserPresentation
 
-    actions += [
-        Action(
+    _context.action(
         discriminator = ('defaultViewName', for_, type, name),
         callable = handler,
         args = ('Views','setDefaultViewName', for_, type, name),
         )
-        ]
-    if for_ is not None:
-        actions.append
-        (
-        Action(
-        discriminator = None,
-        callable = handler,
-        args = (Interfaces, 'provideInterface',
-                for_.__module__+'.'+for_.__name__,
-                for_)
-              )
-        )
 
-
-    return actions
+    if for_ is not None:
+        _context.action(
+            discriminator = None,
+            callable = handler,
+            args = (Interfaces, 'provideInterface',
+                    for_.__module__+'.'+for_.__name__,
+                    for_)
+            )


=== Zope3/src/zope/app/publisher/browser/resourcemeta.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/publisher/browser/resourcemeta.py:1.9	Sat Aug  2 05:11:21 2003
+++ Zope3/src/zope/app/publisher/browser/resourcemeta.py	Sat Aug  2 22:13:17 2003
@@ -17,18 +17,12 @@
 """
 
 from zope.security.checker import CheckerPublic, NamesChecker
-
-from zope.configuration.action import Action
 from zope.configuration.exceptions import ConfigurationError
-
 from zope.app.services.servicenames import Resources
-
 from zope.publisher.interfaces.browser import IBrowserPresentation
-
 from zope.app.component.metaconfigure import handler
 
-from zope.app.publisher.browser.fileresource import FileResourceFactory
-from zope.app.publisher.browser.fileresource import ImageResourceFactory
+from fileresource import FileResourceFactory, ImageResourceFactory
 
 allowed_names = ('GET', 'HEAD', 'publishTraverse', 'browserDefault',
                  'request', '__call__')
@@ -52,11 +46,9 @@
     else:
         factory = ImageResourceFactory(_context.path(image), checker)
 
-    return [
-        Action(
-            discriminator = ('resource', name, IBrowserPresentation, layer),
-            callable = handler,
-            args = (Resources, 'provideResource',
-                    name, IBrowserPresentation, factory, layer),
-            )
-        ]
+    _context.action(
+        discriminator = ('resource', name, IBrowserPresentation, layer),
+        callable = handler,
+        args = (Resources, 'provideResource',
+                name, IBrowserPresentation, factory, layer),
+        )


=== Zope3/src/zope/app/publisher/browser/viewmeta.py 1.29 => 1.30 ===
--- Zope3/src/zope/app/publisher/browser/viewmeta.py:1.29	Sat Aug  2 05:11:21 2003
+++ Zope3/src/zope/app/publisher/browser/viewmeta.py	Sat Aug  2 22:13:17 2003
@@ -27,7 +27,6 @@
 from zope.security.checker import CheckerPublic, Checker
 from zope.security.checker import defineChecker
 
-from zope.configuration.action import Action
 from zope.configuration.exceptions import ConfigurationError
 
 from zope.app.services.servicenames import Interfaces, Views
@@ -37,7 +36,7 @@
 
 from zope.publisher.browser import BrowserView
 
-from zope.app.component.metaconfigure import handler, resolveInterface
+from zope.app.component.metaconfigure import handler
 
 from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
@@ -102,16 +101,16 @@
 
 def page(_context, name, permission, for_,
          layer='default', template=None, class_=None,
-         allowed_interface='', allowed_attributes='',
+         allowed_interface=None, allowed_attributes=None,
          attribute='__call__', menu=None, title=None, 
          usage=u''
          ):
 
-    actions = _handle_menu(_context, menu, title, for_, name, permission)
+    _handle_menu(_context, menu, title, for_, name, permission)
 
     required = {}
 
-    permission = _handle_permission(_context, permission, actions)
+    permission = _handle_permission(_context, permission)
 
     if not (class_ or template):
         raise ConfigurationError("Must specify a class or template")
@@ -132,20 +131,18 @@
         required['__getitem__'] = permission
 
     if class_:
-        original_class = _context.resolve(class_)
-
         if attribute != '__call__':
-            if not hasattr(original_class, attribute):
+            if not hasattr(class_, attribute):
                 raise ConfigurationError(
                     "The provided class doesn't have the specified attribute "
                     )
         if template:
             # class and template
             new_class = SimpleViewClass(
-                template, bases=(original_class, ), usage=usage
+                template, bases=(class_, ), usage=usage
                 )
         else:
-            if not hasattr(original_class, 'browserDefault'):
+            if not hasattr(class_, 'browserDefault'):
                 cdict = {
                     'browserDefault':
                     ContextMethod(lambda self, request:
@@ -156,12 +153,12 @@
                 cdict = {}
 
             cdict['__page_attribute__'] = attribute
-            new_class = type(original_class.__name__,
-                          (original_class, simple,),
-                          cdict)
+            new_class = type(class_.__name__,
+                             (class_, simple,),
+                             cdict)
             new_class.usage = usage
 
-        if hasattr(original_class, '__implements__'):
+        if hasattr(class_, '__implements__'):
             classImplements(new_class, IBrowserPublisher)
             classImplements(new_class, IBrowserPresentation)
 
@@ -173,31 +170,26 @@
         required[n] = permission
 
     _handle_allowed_interface(_context, allowed_interface, permission,
-                              required, actions)
+                              required)
     _handle_allowed_attributes(_context, allowed_interface, permission,
                                required)
-    for_ = _handle_for(_context, for_, actions)
+    _handle_for(_context, for_)
 
     defineChecker(new_class, Checker(required))
 
-    actions.append(
-        Action(
-          discriminator = ('view', for_, name, IBrowserPresentation, layer),
-          callable = handler,
-          args = (Views, 'provideView',
-                  for_, name, IBrowserPresentation, [new_class], layer),
-          )
+    _context.action(
+        discriminator = ('view', for_, name, IBrowserPresentation, layer),
+        callable = handler,
+        args = (Views, 'provideView',
+                for_, name, IBrowserPresentation, [new_class], layer),
         )
 
     if not usage and menu:
-        actions.append(
-            Action(discriminator = None,
+        _context.action(
+            discriminator = None,
             callable = _handle_usage_from_menu,
             args = (new_class, menu, ),
             )
-        )
-
-    return actions
 
 
 # pages, which are just a short-hand for multiple page directives.
@@ -212,7 +204,7 @@
 
     def __init__(self, _context, for_, permission,
                  layer='default', class_=None,
-                 allowed_interface='', allowed_attributes='',
+                 allowed_interface=None, allowed_attributes=None,
                  ):
         self.opts = opts(for_=for_, permission=permission,
                          layer=layer, class_=class_,
@@ -244,19 +236,16 @@
 
     def __init__(self, _context, name, for_, permission,
                  layer='default', class_=None,
-                 allowed_interface='', allowed_attributes='',
+                 allowed_interface=None, allowed_attributes=None,
                  menu=None, title=None, usage=u''
                  ):
 
-        actions = _handle_menu(_context, menu, title, for_, name, permission)
-
-        if class_:
-            class_ = _context.resolve(class_)
+        _handle_menu(_context, menu, title, for_, name, permission)
 
-        permission = _handle_permission(_context, permission, actions)
+        permission = _handle_permission(_context, permission)
 
         self.args = (_context, name, for_, permission, layer, class_,
-                     allowed_interface, allowed_attributes, actions)
+                     allowed_interface, allowed_attributes)
 
         self.pages = []
         # default usage is u''
@@ -281,9 +270,8 @@
         return ()
 
     def __call__(self):
-
         (_context, name, for_, permission, layer, class_,
-         allowed_interface, allowed_attributes, actions) = self.args
+         allowed_interface, allowed_attributes) = self.args
 
         required = {}
 
@@ -362,28 +350,23 @@
             required[n] = permission
 
         _handle_allowed_interface(_context, allowed_interface, permission,
-                                  required, actions)
+                                  required)
         _handle_allowed_attributes(_context, allowed_interface, permission,
                                    required)
-        for_ = _handle_for(_context, for_, actions)
+        _handle_for(_context, for_)
 
         defineChecker(newclass, Checker(required))
 
-        actions.append(
-            Action(
-              discriminator = ('view',
-                               for_, name, IBrowserPresentation, layer),
-              callable = handler,
-              args = (Views, 'provideView',
-                      for_, name, IBrowserPresentation, [newclass], layer),
-              )
+        _context.action(
+            discriminator = ('view', for_, name, IBrowserPresentation, layer),
+            callable = handler,
+            args = (Views, 'provideView',
+                    for_, name, IBrowserPresentation, [newclass], layer),
             )
 
-        return actions
-
 def addview(_context, name, permission,
             layer='default', class_=None,
-            allowed_interface='', allowed_attributes='',
+            allowed_interface=None, allowed_attributes=None,
             menu=None, title=None, usage=u'',
             ):
     return view(_context, name,
@@ -396,29 +379,20 @@
 
 def defaultView(_context, name, for_=None):
 
-    if for_ is not None:
-        for_ = resolveInterface(_context, for_)
-
-    actions = [
-        Action(
+    _context.action(
         discriminator = ('defaultViewName', for_, IBrowserPresentation, name),
         callable = handler,
         args = (Views,'setDefaultViewName', for_, IBrowserPresentation,
                 name),
-        )]
+        )
 
     if for_ is not None:
-        actions .append(
-            Action(
+        _context.action(
             discriminator = None,
             callable = handler,
             args = (Interfaces, 'provideInterface',
-                    for_.__module__+'.'+for_.__name__,
-                    for_)
+                    for_.__module__+'.'+for_.__name__, for_)
             )
-        )
-
-    return actions
 
 def _handle_menu(_context, menu, title, for_, name, permission):
     if menu or title:
@@ -434,52 +408,49 @@
     return []
 
 
-def _handle_permission(_context, permission, actions):
+def _handle_permission(_context, permission):
     if permission == 'zope.Public':
         permission = CheckerPublic
     else:
-        actions.append(Action(discriminator = None, callable = checkPermission,
-                              args = (None, permission)))
+        _context.action(
+            discriminator = None,
+            callable = checkPermission,
+            args = (None, permission)
+            )
 
     return permission
 
 def _handle_allowed_interface(_context, allowed_interface, permission,
-                              required, actions):
+                              required):
     # Allow access for all names defined by named interfaces
-    if allowed_interface.strip():
-        for i in allowed_interface.strip().split():
-            i = resolveInterface(_context, i)
-            actions .append(
-                Action(discriminator = None, callable = handler,
-                       args = (Interfaces, 'provideInterface', None, i)
-                       ))
+    if allowed_interface:
+        for i in allowed_interface:
+            _context.action(
+                discriminator = None,
+                callable = handler,
+                args = (Interfaces, 'provideInterface', None, i)
+                )
             for name in i:
                 required[name] = permission
 
 def _handle_allowed_attributes(_context, allowed_attributes, permission,
                                required):
     # Allow access for all named attributes
-    if allowed_attributes.strip():
-        for name in allowed_attributes.strip().split():
+    if allowed_attributes:
+        for name in allowed_attributes:
             required[name] = permission
 
 def _handle_usage_from_menu(view, menu_id):
     usage = globalBrowserMenuService.getMenuUsage(menu_id)
     view.usage = usage
 
-def _handle_for(_context, for_, actions):
-    if for_ == '*':
-        for_ = None
-
+def _handle_for(_context, for_):
     if for_ is not None:
-        for_ = resolveInterface(_context, for_)
-
-        actions .append(
-            Action(discriminator = None, callable = handler,
-                   args = (Interfaces, 'provideInterface', None, for_)
-            ))
-
-    return for_
+        _context.action(
+            discriminator = None,
+            callable = handler,
+            args = (Interfaces, 'provideInterface', None, for_)
+            )
 
 class simple(BrowserView):
     implements(IBrowserPublisher)




More information about the Zope3-Checkins mailing list