[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser - globalbrowsermenuservice.py:1.20 i18nresourcemeta.py:1.12 icon.py:1.9 meta.zcml:1.11 metaconfigure.py:1.10 resourcemeta.py:1.9 viewmeta.py:1.29 metadirectives.py:NONE
Anthony Baxter
anthony@interlink.com.au
Sat, 2 Aug 2003 05:11:59 -0400
Update of /cvs-repository/Zope3/src/zope/app/publisher/browser
In directory cvs.zope.org:/tmp/cvs-serv24272/zope/app/publisher/browser
Modified Files:
globalbrowsermenuservice.py i18nresourcemeta.py icon.py
meta.zcml metaconfigure.py resourcemeta.py viewmeta.py
Removed Files:
metadirectives.py
Log Message:
Backing out philiKON's changes - they broke the functional tests, and
from his signoff on IRC, I don't think he's going to be around until
Monday. As I'm working on the Catalog functional tests, this is pretty
annoying. I tried to figure out how to just back out bits til I found the
broken stuff, but it's a pretty serious refactoring. I'll send a message
to zope3-checkins with the CVS commands used for this, so that someone
can undo the backout if they wish.
=== Zope3/src/zope/app/publisher/browser/globalbrowsermenuservice.py 1.19 => 1.20 ===
--- Zope3/src/zope/app/publisher/browser/globalbrowsermenuservice.py:1.19 Sat Aug 2 03:04:09 2003
+++ Zope3/src/zope/app/publisher/browser/globalbrowsermenuservice.py Sat Aug 2 05:11:21 2003
@@ -15,6 +15,8 @@
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
@@ -25,7 +27,7 @@
from zope.app.security.permission import checkPermission
-from zope.app.component.metaconfigure import handler
+from zope.app.component.metaconfigure import handler, resolveInterface
from zope.app.interfaces.publisher.browser import IBrowserMenuService
from zope.app.pagetemplate.engine import Engine
from zope.app.publication.browser import PublicationTraverser
@@ -173,11 +175,11 @@
return None
def menuDirective(_context, id, title, description='', usage=u''):
- _context.action(
+ return [Action(
discriminator = ('browser:menu', id),
callable = globalBrowserMenuService.menu,
args = (id, title, description, usage),
- )
+ )]
def menuItemDirective(_context, menu, for_,
action, title, description='', filter=None,
@@ -189,27 +191,36 @@
class menuItemsDirective:
def __init__(self, _context, menu, for_):
- self.interface = for_
+ if for_ == '*':
+ self.interface = None
+ else:
+ self.interface = resolveInterface(_context, for_)
self.menu = menu
def menuItem(self, _context, action, title, description='',
filter=None, permission=None):
- _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)
- )
+
+ 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)
+ )
+ ]
+
globalBrowserMenuService = GlobalBrowserMenuService()
=== Zope3/src/zope/app/publisher/browser/i18nresourcemeta.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/publisher/browser/i18nresourcemeta.py:1.11 Sat Aug 2 03:04:09 2003
+++ Zope3/src/zope/app/publisher/browser/i18nresourcemeta.py Sat Aug 2 05:11:21 2003
@@ -20,13 +20,17 @@
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 i18nfileresource import I18nFileResourceFactory
+from zope.app.publisher.browser.i18nfileresource import I18nFileResourceFactory
class I18nResource(object):
@@ -35,7 +39,6 @@
def __init__(self, _context, name=None, defaultLanguage='en',
layer='default', permission=None):
- self._context = _context
self.name = name
self.defaultLanguage = defaultLanguage
self.layer = layer
@@ -43,6 +46,7 @@
self.__data = {}
self.__format = None
+
def translation(self, _context, language, file=None, image=None):
if file is not None and image is not None:
@@ -100,12 +104,15 @@
factory = self._proxyFactory(factory, checker)
- self._context.action(
- discriminator = ('i18n-resource', self.name, self.type, self.layer),
- callable = handler,
- args = (Resources, 'provideResource', self.name, self.type,
- factory, self.layer)
- )
+ return [
+ 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.8 => 1.9 ===
--- Zope3/src/zope/app/publisher/browser/icon.py:1.8 Sat Aug 2 03:04:09 2003
+++ Zope3/src/zope/app/publisher/browser/icon.py Sat Aug 2 05:11:21 2003
@@ -20,7 +20,8 @@
import os
import re
-from zope.app.component.metaconfigure import handler
+from zope.app.component.metaconfigure import handler, resolveInterface
+from zope.configuration.action import Action
from zope.app.publisher.browser import metaconfigure
from zope.app.traversing.namespace import getResourceInContext
from zope.publisher.interfaces.browser import IBrowserPresentation
@@ -63,6 +64,7 @@
def IconDirective(_context, name, for_, file=None, resource=None,
layer='default', alt=None):
+ for_ = resolveInterface(_context, for_)
iname = for_.__name__
if alt is None:
@@ -70,6 +72,7 @@
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 "
@@ -81,8 +84,8 @@
ext = os.path.splitext(file)[1]
if ext:
resource += ext
- metaconfigure.resource(_context, image=file,
- name=resource, layer=layer)
+ results = metaconfigure.resource(_context, image=file,
+ name=resource, layer=layer)
elif resource is None:
raise ConfigurationError(
"At least one of the file, and resource "
@@ -91,17 +94,18 @@
vfactory = IconViewFactory(resource, alt)
- _context.action(
+ return results + [
+ Action(
discriminator = ('view', name, vfactory, layer),
callable = handler,
args = ('Views', 'provideView',
for_, name, IBrowserPresentation,
- vfactory, layer)
- )
- _context.action(
+ vfactory, layer)),
+ Action(
discriminator = None,
callable = handler,
args = (Interfaces, 'provideInterface',
for_.__module__+'.'+for_.__name__,
for_)
)
+ ]
=== Zope3/src/zope/app/publisher/browser/meta.zcml 1.10 => 1.11 ===
--- Zope3/src/zope/app/publisher/browser/meta.zcml:1.10 Sat Aug 2 03:04:09 2003
+++ Zope3/src/zope/app/publisher/browser/meta.zcml Sat Aug 2 05:11:21 2003
@@ -1,139 +1,847 @@
-<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"
+<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"
>
- <meta:subdirective
- name="page"
- schema=".metadirectives.IViewPageSubdirective"
- />
+ <attribute name="name" required="yes">
- <meta:subdirective
- name="defaultPage"
- schema=".metadirectives.IViewDefaultPageSubdirective"
- />
+ <description>
+ The name of the resource
- </meta:complexDirective>
+ 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.
- <meta:complexDirective
- name="addview"
- schema=".metadirectives.IViewDirective"
- handler=".viewmeta.addview"
- >
+ We make resource urls site-relative (as opposed to
+ content-relative) so as not to defeat caches.
+ </description>
- <meta:subdirective
- name="page"
- schema=".metadirectives.IViewPageSubdirective"
- />
+ </attribute>
- <meta:subdirective
- name="defaultPage"
- schema=".metadirectives.IViewDefaultPageSubdirective"
- />
+ <attribute name="layer" required="no">
- </meta:complexDirective>
+ <description>
+ The layer the resource should be found in
- <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"
- >
+ For information on layers, see the documentation for the
+ skin directive.
- <meta:subdirective
- name="page"
- schema=".metadirectives.IPagesPageSubdirective"
- />
+ Defaults to "default".
+ </description>
+
+ </attribute>
+
+ <attribute name="file">
+
+ <description>
+ The file containing the resource data.
+ </description>
+
+ </attribute>
+
+ <attribute name="image">
- </meta:complexDirective>
+ <description>
+ The file containing the resource data.
+ If the image attribute is used, then an image resource,
+ rather than a file resource will be created.
+ </description>
- <!-- browser resources -->
+ </attribute>
- <meta:directive
- name="resource"
- schema=".metadirectives.IResourceDirective"
- handler=".metaconfigure.resource"
- />
+ <attribute name="permission" required="no">
- <meta:complexDirective
+ <description>
+ The id of the permission needed to access the resource.
+
+ If a permission isn't specified, the resource will always
+ be accessible.
+ </description>
+
+ </attribute>
+
+ </directive>
+
+ <directive
name="i18n-resource"
- schema=".metadirectives.II18nResourceDirective"
- handler=".metaconfigure.I18nResource"
+ 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"
>
- <meta:subdirective
- name="translation"
- schema=".metadirectives.II18nResourceTranslationSubdirective"
- />
+ <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"
+ >
- </meta:complexDirective>
+ <attribute name="id">
+ <description>
+ The name of the menu.
+
+ This is, effectively, an id.
+ </description>
+ </attribute>
- <!-- browser menus -->
+ <attribute
+ name="title"
+ description="A descriptive title for documentation purposes"
+ />
+
+ <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>
+
+ </directive>
- <meta:directive
- name="menu"
- schema=".metadirectives.IMenuDirective"
- handler=".globalbrowsermenuservice.menuDirective"
- />
- <meta:complexDirective
+
+ <directive
name="menuItems"
- schema=".metadirectives.IMenuItemsDirective"
- handler=".globalbrowsermenuservice.menuItemsDirective"
+ attributes="menu for"
+ handler="
+ zope.app.publisher.browser.globalbrowsermenuservice.menuItemsDirective"
>
+ <description>
+ Define a group of browser menu items
- <meta:subdirective
- name="menuItem"
- schema=".metadirectives.IMenuItemSubdirective"
+ 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:complexDirective>
+ <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: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"
- />
+ <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:directives>
+ </directives>
-</configure>
+</zopeConfigure>
=== Zope3/src/zope/app/publisher/browser/metaconfigure.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/publisher/browser/metaconfigure.py:1.9 Sat Aug 2 03:04:09 2003
+++ Zope3/src/zope/app/publisher/browser/metaconfigure.py Sat Aug 2 05:11:21 2003
@@ -16,11 +16,13 @@
$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
+from zope.app.component.metaconfigure import handler, resolveInterface
# referred to through ZCML
from zope.app.publisher.browser.resourcemeta import resource
@@ -29,26 +31,40 @@
from zope.app.publisher.browser.viewmeta import view
def skin(_context, **__kw):
- return _skin(_context, type=IBrowserPresentation, **__kw)
+ return _skin(_context,
+ type='zope.publisher.interfaces.browser.IBrowserPresentation',
+ **__kw)
def defaultView(_context, name, for_=None, **__kw):
if __kw:
- view(_context, name=name, for_=for_, **__kw)()
+ actions = view(_context, name=name, for_=for_, **__kw)()
+ else:
+ actions = []
+
+ if for_ is not None:
+ for_ = resolveInterface(_context, for_)
type = IBrowserPresentation
- _context.action(
+ actions += [
+ Action(
discriminator = ('defaultViewName', for_, type, name),
callable = handler,
args = ('Views','setDefaultViewName', for_, type, name),
)
-
+ ]
if for_ is not None:
- _context.action(
- discriminator = None,
- callable = handler,
- args = (Interfaces, 'provideInterface',
- for_.__module__+'.'+for_.__name__,
- for_)
- )
+ actions.append
+ (
+ Action(
+ discriminator = None,
+ callable = handler,
+ args = (Interfaces, 'provideInterface',
+ for_.__module__+'.'+for_.__name__,
+ for_)
+ )
+ )
+
+
+ return actions
=== Zope3/src/zope/app/publisher/browser/resourcemeta.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/publisher/browser/resourcemeta.py:1.8 Sat Aug 2 03:04:09 2003
+++ Zope3/src/zope/app/publisher/browser/resourcemeta.py Sat Aug 2 05:11:21 2003
@@ -17,12 +17,18 @@
"""
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 fileresource import FileResourceFactory, ImageResourceFactory
+from zope.app.publisher.browser.fileresource import FileResourceFactory
+from zope.app.publisher.browser.fileresource import ImageResourceFactory
allowed_names = ('GET', 'HEAD', 'publishTraverse', 'browserDefault',
'request', '__call__')
@@ -46,9 +52,11 @@
else:
factory = ImageResourceFactory(_context.path(image), checker)
- _context.action(
- discriminator = ('resource', name, IBrowserPresentation, layer),
- callable = handler,
- args = (Resources, 'provideResource',
- name, IBrowserPresentation, factory, layer),
- )
+ return [
+ Action(
+ discriminator = ('resource', name, IBrowserPresentation, layer),
+ callable = handler,
+ args = (Resources, 'provideResource',
+ name, IBrowserPresentation, factory, layer),
+ )
+ ]
=== Zope3/src/zope/app/publisher/browser/viewmeta.py 1.28 => 1.29 ===
--- Zope3/src/zope/app/publisher/browser/viewmeta.py:1.28 Sat Aug 2 03:04:09 2003
+++ Zope3/src/zope/app/publisher/browser/viewmeta.py Sat Aug 2 05:11:21 2003
@@ -27,6 +27,7 @@
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
@@ -36,7 +37,7 @@
from zope.publisher.browser import BrowserView
-from zope.app.component.metaconfigure import handler
+from zope.app.component.metaconfigure import handler, resolveInterface
from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
@@ -101,16 +102,16 @@
def page(_context, name, permission, for_,
layer='default', template=None, class_=None,
- allowed_interface=None, allowed_attributes=None,
+ allowed_interface='', allowed_attributes='',
attribute='__call__', menu=None, title=None,
usage=u''
):
- _handle_menu(_context, menu, title, for_, name, permission)
+ actions = _handle_menu(_context, menu, title, for_, name, permission)
required = {}
- permission = _handle_permission(_context, permission)
+ permission = _handle_permission(_context, permission, actions)
if not (class_ or template):
raise ConfigurationError("Must specify a class or template")
@@ -131,18 +132,20 @@
required['__getitem__'] = permission
if class_:
+ original_class = _context.resolve(class_)
+
if attribute != '__call__':
- if not hasattr(class_, attribute):
+ if not hasattr(original_class, attribute):
raise ConfigurationError(
"The provided class doesn't have the specified attribute "
)
if template:
# class and template
new_class = SimpleViewClass(
- template, bases=(class_, ), usage=usage
+ template, bases=(original_class, ), usage=usage
)
else:
- if not hasattr(class_, 'browserDefault'):
+ if not hasattr(original_class, 'browserDefault'):
cdict = {
'browserDefault':
ContextMethod(lambda self, request:
@@ -153,12 +156,12 @@
cdict = {}
cdict['__page_attribute__'] = attribute
- new_class = type(class_.__name__,
- (class_, simple,),
- cdict)
+ new_class = type(original_class.__name__,
+ (original_class, simple,),
+ cdict)
new_class.usage = usage
- if hasattr(class_, '__implements__'):
+ if hasattr(original_class, '__implements__'):
classImplements(new_class, IBrowserPublisher)
classImplements(new_class, IBrowserPresentation)
@@ -170,26 +173,31 @@
required[n] = permission
_handle_allowed_interface(_context, allowed_interface, permission,
- required)
+ required, actions)
_handle_allowed_attributes(_context, allowed_interface, permission,
required)
- for_ = _handle_for(_context, for_)
+ for_ = _handle_for(_context, for_, actions)
defineChecker(new_class, Checker(required))
- _context.action(
- discriminator = ('view', for_, name, IBrowserPresentation, layer),
- callable = handler,
- args = (Views, 'provideView',
- for_, name, IBrowserPresentation, [new_class], layer),
+ actions.append(
+ Action(
+ discriminator = ('view', for_, name, IBrowserPresentation, layer),
+ callable = handler,
+ args = (Views, 'provideView',
+ for_, name, IBrowserPresentation, [new_class], layer),
+ )
)
if not usage and menu:
- _context.action(
- discriminator = None,
+ actions.append(
+ 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.
@@ -204,7 +212,7 @@
def __init__(self, _context, for_, permission,
layer='default', class_=None,
- allowed_interface=None, allowed_attributes=None,
+ allowed_interface='', allowed_attributes='',
):
self.opts = opts(for_=for_, permission=permission,
layer=layer, class_=class_,
@@ -236,16 +244,19 @@
def __init__(self, _context, name, for_, permission,
layer='default', class_=None,
- allowed_interface=None, allowed_attributes=None,
+ allowed_interface='', allowed_attributes='',
menu=None, title=None, usage=u''
):
- _handle_menu(_context, menu, title, for_, name, permission)
+ actions = _handle_menu(_context, menu, title, for_, name, permission)
+
+ if class_:
+ class_ = _context.resolve(class_)
- permission = _handle_permission(_context, permission)
+ permission = _handle_permission(_context, permission, actions)
self.args = (_context, name, for_, permission, layer, class_,
- allowed_interface, allowed_attributes)
+ allowed_interface, allowed_attributes, actions)
self.pages = []
# default usage is u''
@@ -270,8 +281,9 @@
return ()
def __call__(self):
+
(_context, name, for_, permission, layer, class_,
- allowed_interface, allowed_attributes) = self.args
+ allowed_interface, allowed_attributes, actions) = self.args
required = {}
@@ -350,23 +362,28 @@
required[n] = permission
_handle_allowed_interface(_context, allowed_interface, permission,
- required)
+ required, actions)
_handle_allowed_attributes(_context, allowed_interface, permission,
required)
- for_ = _handle_for(_context, for_)
+ for_ = _handle_for(_context, for_, actions)
defineChecker(newclass, Checker(required))
- _context.action(
- discriminator = ('view', for_, name, IBrowserPresentation, layer),
- callable = handler,
- args = (Views, 'provideView',
- for_, name, IBrowserPresentation, [newclass], layer),
+ actions.append(
+ 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=None, allowed_attributes=None,
+ allowed_interface='', allowed_attributes='',
menu=None, title=None, usage=u'',
):
return view(_context, name,
@@ -379,20 +396,29 @@
def defaultView(_context, name, for_=None):
- _context.action(
+ if for_ is not None:
+ for_ = resolveInterface(_context, for_)
+
+ actions = [
+ Action(
discriminator = ('defaultViewName', for_, IBrowserPresentation, name),
callable = handler,
args = (Views,'setDefaultViewName', for_, IBrowserPresentation,
name),
- )
+ )]
if for_ is not None:
- _context.action(
+ actions .append(
+ 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:
@@ -408,52 +434,50 @@
return []
-def _handle_permission(_context, permission):
+def _handle_permission(_context, permission, actions):
if permission == 'zope.Public':
permission = CheckerPublic
else:
- _context.action(
- discriminator = None,
- callable = checkPermission,
- args = (None, permission)
- )
+ actions.append(Action(discriminator = None, callable = checkPermission,
+ args = (None, permission)))
return permission
def _handle_allowed_interface(_context, allowed_interface, permission,
- required):
+ required, actions):
# Allow access for all names defined by named interfaces
- if allowed_interface:
- for i in allowed_interface:
- _context.action(
- discriminator = None,
- callable = handler,
- args = (Interfaces, 'provideInterface', None, i)
- )
+ 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)
+ ))
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:
- for name in allowed_attributes:
+ if allowed_attributes.strip():
+ for name in allowed_attributes.strip().split():
required[name] = permission
def _handle_usage_from_menu(view, menu_id):
usage = globalBrowserMenuService.getMenuUsage(menu_id)
view.usage = usage
-def _handle_for(_context, for_):
+def _handle_for(_context, for_, actions):
if for_ == '*':
for_ = None
if for_ is not None:
- _context.action(
- discriminator = None,
- callable = handler,
- args = (Interfaces, 'provideInterface', None, for_)
- )
+ for_ = resolveInterface(_context, for_)
+
+ actions .append(
+ Action(discriminator = None, callable = handler,
+ args = (Interfaces, 'provideInterface', None, for_)
+ ))
return for_
=== Removed File Zope3/src/zope/app/publisher/browser/metadirectives.py ===