[Zope3-checkins] CVS: Zope3/src/zope/app/component -
metaconfigure.py:1.22 metadirectives.py:1.9
Jim Fulton
jim at zope.com
Wed Dec 17 05:06:21 EST 2003
Update of /cvs-repository/Zope3/src/zope/app/component
In directory cvs.zope.org:/tmp/cvs-serv32331/src/zope/app/component
Modified Files:
metaconfigure.py metadirectives.py
Log Message:
Added a provides attribute to zope:view and zope:resource directives
to allow registration of views that provide interfaces.
=== Zope3/src/zope/app/component/metaconfigure.py 1.21 => 1.22 ===
--- Zope3/src/zope/app/component/metaconfigure.py:1.21 Sun Dec 7 05:04:51 2003
+++ Zope3/src/zope/app/component/metaconfigure.py Wed Dec 17 05:06:20 2003
@@ -25,6 +25,7 @@
Checker, NamesChecker
from zope.app.security.registries.permissionregistry import permissionRegistry
from zope.component.service import UndefinedService
+import zope.interface
PublicPermission = 'zope.Public'
@@ -175,7 +176,8 @@
def resource(_context, factory, type, name, layer='default',
permission=None,
- allowed_interface=None, allowed_attributes=None):
+ allowed_interface=None, allowed_attributes=None,
+ provides=zope.interface.Interface):
if ((allowed_attributes or allowed_interface)
and (not permission)):
@@ -195,20 +197,27 @@
factory = proxyResource
_context.action(
- discriminator = ('resource', name, type, layer),
+ discriminator = ('resource', name, type, layer, provides),
callable = checkingHandler,
args = (permission, Presentation, 'provideResource',
- name, type, factory, layer),
+ name, type, factory, layer, provides),
)
_context.action(
discriminator = None,
callable = handler,
args = (Interfaces, 'provideInterface',
- type.__module__+'.'+type.getName(), type)
+ type.__module__+'.'+type.__name__, type)
+ )
+ _context.action(
+ discriminator = None,
+ callable = handler,
+ args = (Interfaces, 'provideInterface',
+ provides.__module__+'.'+provides.__name__, type)
)
def view(_context, factory, type, name, for_, layer='default',
- permission=None, allowed_interface=None, allowed_attributes=None):
+ permission=None, allowed_interface=None, allowed_attributes=None,
+ provides=zope.interface.Interface):
if for_ == '*':
for_ = None
@@ -234,16 +243,22 @@
factory[-1] = proxyView
_context.action(
- discriminator = ('view', for_, name, type, layer),
+ discriminator = ('view', for_, name, type, layer, provides),
callable = checkingHandler,
args = (permission, Presentation, 'provideView', for_, name,
- type, factory, layer),
+ type, factory, layer, provides),
+ )
+ _context.action(
+ discriminator = None,
+ callable = handler,
+ args = (Interfaces, 'provideInterface',
+ type.__module__+'.'+type.__name__, type)
)
_context.action(
discriminator = None,
callable = handler,
args = (Interfaces, 'provideInterface',
- type.__module__+'.'+type.getName(), type)
+ provides.__module__+'.'+provides.__name__, type)
)
if for_ is not None:
=== Zope3/src/zope/app/component/metadirectives.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/component/metadirectives.py:1.8 Sun Dec 14 03:48:59 2003
+++ Zope3/src/zope/app/component/metadirectives.py Wed Dec 17 05:06:20 2003
@@ -105,11 +105,21 @@
name = TextLine(
title=u"The name of the resource.",
description=u"The name shows up in URLs/paths. For example 'foo'.",
- required=True
+ required=True,
+ default=u'',
+ )
+
+ provides = GlobalObject(
+ title=u"The interface this provides.",
+ description=u"""
+ A view can provide an interface. This would be used for
+ views that support other views.""",
+ required=False,
+ default=Interface,
)
type = GlobalObject(
- title=u"Type of the resource",
+ title=u"Request type",
required=True
)
@@ -209,7 +219,8 @@
value_type=GlobalObject()
)
-class IResourceDirective(IBasicComponentInformation, IBasicResourceInformation):
+class IResourceDirective(IBasicComponentInformation,
+ IBasicResourceInformation):
"""
Register a resource
"""
More information about the Zope3-Checkins
mailing list