[Zope3-checkins] SVN: Zope3/trunk/src/zope/ Moved support for
layers back into zope:view. Removed support for multiple
'for's in browser:view because it's YAGNI/WHUI.
Garrett Smith
garrett at mojave-corp.com
Mon Nov 8 19:44:52 EST 2004
Log message for revision 28407:
Moved support for layers back into zope:view. Removed support for multiple 'for's in browser:view because it's YAGNI/WHUI.
When a 'layer' is not specified in zope:view, the default layer for the view 'type' is used, if available. A new directive zope:defaultLayer is used to specify a default layer for a request type.
Changed IDefaultLayer to IDefaultBrowserLayer since there can be other default layer types.
Changed:
U Zope3/trunk/src/zope/app/component/fields.py
U Zope3/trunk/src/zope/app/component/meta.zcml
U Zope3/trunk/src/zope/app/component/metaconfigure.py
U Zope3/trunk/src/zope/app/component/metadirectives.py
A Zope3/trunk/src/zope/app/component/tests/test_fields.py
U Zope3/trunk/src/zope/app/container/browser/metaconfigure.py
U Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py
U Zope3/trunk/src/zope/app/form/browser/add.py
U Zope3/trunk/src/zope/app/form/browser/addwizard.py
U Zope3/trunk/src/zope/app/form/browser/editview.py
U Zope3/trunk/src/zope/app/form/browser/editwizard.py
U Zope3/trunk/src/zope/app/form/browser/metaconfigure.py
U Zope3/trunk/src/zope/app/form/browser/metadirectives.py
U Zope3/trunk/src/zope/app/form/browser/schemadisplay.py
U Zope3/trunk/src/zope/app/form/browser/tests/test_add.py
U Zope3/trunk/src/zope/app/pagelet/metaconfigure.py
U Zope3/trunk/src/zope/app/pagelet/metadirectives.py
U Zope3/trunk/src/zope/app/pagelet/tales.py
U Zope3/trunk/src/zope/app/publication/httpfactory.py
U Zope3/trunk/src/zope/app/publisher/browser/configure.zcml
U Zope3/trunk/src/zope/app/publisher/browser/fields.py
U Zope3/trunk/src/zope/app/publisher/browser/i18nresourcemeta.py
U Zope3/trunk/src/zope/app/publisher/browser/icon.py
U Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
U Zope3/trunk/src/zope/app/publisher/browser/metadirectives.py
U Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py
U Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py
U Zope3/trunk/src/zope/app/rotterdam/__init__.py
U Zope3/trunk/src/zope/app/site/browser/metaconfigure.py
U Zope3/trunk/src/zope/app/tests/functional.py
U Zope3/trunk/src/zope/app/tests/ztapi.py
U Zope3/trunk/src/zope/publisher/browser.py
U Zope3/trunk/src/zope/publisher/interfaces/__init__.py
U Zope3/trunk/src/zope/publisher/interfaces/browser.py
-=-
Modified: Zope3/trunk/src/zope/app/component/fields.py
===================================================================
--- Zope3/trunk/src/zope/app/component/fields.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/component/fields.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -17,15 +17,102 @@
"""
__docformat__ = 'restructuredtext'
-# BBB this module can be deleted in 3.3
-import sys
-# hack to let apidoc dynamically load all modules without complaining
-if 'apidoc' not in sys._getframe(10).f_code.co_filename:
- import warnings
- warnings.warn(
- "The class zope.app.component.fields.LayerField is deprecated and will "
- "away in ZopeX3 3.3. Use zope.app.publisher.browser.fields.LayerField "
- "instead.",
- DeprecationWarning)
+import zope.schema
+from zope.component.exceptions import ComponentLookupError
+from zope.configuration.exceptions import ConfigurationError
+from zope.configuration.fields import GlobalObject
+from zope.interface.interfaces import IInterface
+from zope.publisher.interfaces.browser import ILayer
-from zope.app.publisher.browser.fields import LayerField
+from zope.app import zapi
+
+
+class LayerField(GlobalObject):
+ r"""This fields represents a layer.
+
+ Besides being able to look up the layer by importing it, we also try
+ to look up the name in the utility service.
+
+ >>> from zope.interface import directlyProvides
+ >>> from zope.interface.interface import InterfaceClass
+
+ >>> layer1 = InterfaceClass('layer1', (),
+ ... __doc__='Layer: layer1',
+ ... __module__='zope.app.layers')
+ >>> directlyProvides(layer1, ILayer)
+
+ >>> layers = None
+ >>> class Resolver(object):
+ ... def resolve(self, path):
+ ... if '..' in path:
+ ... raise ValueError('Empty module name')
+ ... if (path.startswith('zope.app.layers') and
+ ... hasattr(layers, 'layer1') or
+ ... path == 'zope.app.component.fields.layer1' or
+ ... path == '.fields.layer1'):
+ ... return layer1
+ ... raise ConfigurationError, 'layer1'
+
+ >>> field = LayerField()
+ >>> field = field.bind(Resolver())
+
+ Test 1: Import the layer
+ ------------------------
+
+ >>> field.fromUnicode('zope.app.component.fields.layer1') is layer1
+ True
+
+ Test 2: We have a shortcut name. Import the layer from `zope.app.layers`.
+ -------------------------------------------------------------------------
+
+ >>> from types import ModuleType as module
+ >>> import sys
+ >>> layers = module('layers')
+ >>> old = sys.modules.get('zope.app.layers', None)
+ >>> sys.modules['zope.app.layers'] = layers
+ >>> setattr(layers, 'layer1', layer1)
+
+ >>> field.fromUnicode('layer1') is layer1
+ True
+
+ >>> if old is not None:
+ ... sys.modules['zope.app.layers'] = old
+
+ Test 3: Get the layer from the utility service
+ ----------------------------------------------
+
+ >>> from zope.app.tests import ztapi
+ >>> ztapi.provideUtility(ILayer, layer1, 'layer1')
+
+ >>> field.fromUnicode('layer1') is layer1
+ True
+
+ Test 4: Import the layer by using a short name
+ ----------------------------------------------
+
+ >>> field.fromUnicode('.fields.layer1') is layer1
+ True
+ """
+
+ def fromUnicode(self, u):
+ name = str(u.strip())
+
+ try:
+ value = zapi.queryUtility(ILayer, name)
+ except ComponentLookupError:
+ # The component architecture is not up and running.
+ pass
+ else:
+ if value is not None:
+ return value
+
+ try:
+ value = self.context.resolve('zope.app.layers.'+name)
+ except (ConfigurationError, ValueError), v:
+ try:
+ value = self.context.resolve(name)
+ except ConfigurationError, v:
+ raise zope.schema.ValidationError(v)
+
+ self.validate(value)
+ return value
Modified: Zope3/trunk/src/zope/app/component/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/component/meta.zcml 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/component/meta.zcml 2004-11-09 00:44:51 UTC (rev 28407)
@@ -60,6 +60,12 @@
/>
<meta:directive
+ name="defaultLayer"
+ schema=".metadirectives.IDefaultLayerDirective"
+ handler="zope.app.component.metaconfigure.defaultLayer"
+ />
+
+ <meta:directive
name="service"
schema=".metadirectives.IServiceDirective"
handler="zope.app.component.metaconfigure.service"
Modified: Zope3/trunk/src/zope/app/component/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/component/metaconfigure.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/component/metaconfigure.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -21,6 +21,7 @@
from zope.component.service import UndefinedService
from zope.configuration.exceptions import ConfigurationError
from zope.interface import Interface
+from zope.interface.interfaces import IInterface
from zope.security.checker import InterfaceChecker, CheckerPublic
from zope.security.checker import Checker, NamesChecker
@@ -30,9 +31,6 @@
from zope.app.component.interface import queryInterface
from zope.app.security.adapter import TrustedAdapterFactory
-import warnings
-
-
PublicPermission = 'zope.Public'
# I prefer the indirection (using getService and getServices vs.
@@ -235,20 +233,11 @@
checker = Checker(require)
return checker
-# BBB layer should be removed from args in 3.3
def resource(_context, factory, type, name, layer=None,
permission=None,
allowed_interface=None, allowed_attributes=None,
provides=Interface):
- # BBB This can go away in 3.3
- if layer is not None:
- warnings.warn(
- "The layer attribute is deprecated for the zope:view "
- "directive and will go away in ZopeX3 3.3. Use browser:view "
- "instead.",
- DeprecationWarning)
-
if ((allowed_attributes or allowed_interface)
and (not permission)):
raise ConfigurationError(
@@ -266,11 +255,11 @@
factory = proxyResource
- # BBB can go away in 3.3
if layer is None:
+ layer = zapi.queryAdapter(type, IInterface, 'defaultLayer')
+ if layer is None:
layer = type
- # BBB 'layer' should be changed to 'type' in 3.3
_context.action(
discriminator = ('resource', name, layer, provides),
callable = handler,
@@ -288,19 +277,10 @@
args = (provides.__module__ + '.' + provides.__name__, type)
)
-# BBB layer should be removed from args in 3.3
def view(_context, factory, type, name, for_, layer=None,
permission=None, allowed_interface=None, allowed_attributes=None,
provides=Interface):
- # BBB This can go away in 3.3
- if layer is not None:
- warnings.warn(
- "The layer attribute is deprecated for the zope:view "
- "directive and will go away in ZopeX3 3.3. Use browser:view "
- "instead.",
- DeprecationWarning)
-
if ((allowed_attributes or allowed_interface)
and (not permission)):
raise ConfigurationError(
@@ -347,12 +327,13 @@
ob = f(ob)
return factories[-1](ob, request)
- # Make type/layer one of the required interfaces.
+ # if layer not specified, use default layer for type
if layer is None:
- for_ = for_ + (type,)
- else:
- # BBB can go away in 3.3 -- always use type as required interface
+ layer = zapi.queryAdapter(type, IInterface, 'defaultLayer')
+ if layer is not None:
for_ = for_ + (layer,)
+ else:
+ for_ = for_ + (type,)
_context.action(
discriminator = ('view', for_, name, provides),
@@ -459,3 +440,12 @@
callable = provideService,
args = (serviceType, component, permission),
)
+
+def defaultLayer(_context, type, layer):
+ _context.action(
+ discriminator=('defaultLayer', type, layer),
+ callable=handler,
+ args = (zapi.servicenames.Adapters, 'register',
+ (type,), IInterface, 'defaultLayer',
+ lambda request: layer, _context.info)
+ )
Modified: Zope3/trunk/src/zope/app/component/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/component/metadirectives.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/component/metadirectives.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -22,10 +22,8 @@
import zope.schema
import zope.app.security.fields
+import zope.app.component.fields
-# BBB goes away in 3.3
-from zope.app.publisher.browser.fields import LayerField
-
from zope.app.i18n import ZopeMessageIDFactory as _
@@ -81,8 +79,7 @@
required=False,
)
- # BBB remove this field in 3.3
- layer = LayerField(
+ layer = zope.app.component.fields.LayerField(
title=_("The layer the view is in."),
description=_("""
A skin is composed of layers. It is common to put skin
@@ -341,8 +338,7 @@
IBasicResourceInformation):
"""Register a resource"""
- # BBB remove this field in 3.3
- layer = LayerField(
+ layer = zope.app.component.fields.LayerField(
title=_("The layer the resource is in."),
required=False,
)
@@ -498,3 +494,16 @@
" factory does"),
required=False,
)
+
+class IDefaultLayerDirective(zope.interface.Interface):
+ """Associate a default layer with a request type."""
+
+ type = zope.configuration.fields.GlobalObject(
+ title=_("Request type"),
+ required=True
+ )
+
+ layer = zope.configuration.fields.GlobalObject(
+ title=_("Layer"),
+ required=True
+ )
Copied: Zope3/trunk/src/zope/app/component/tests/test_fields.py (from rev 28317, Zope3/trunk/src/zope/app/component/tests/test_fields.py)
Modified: Zope3/trunk/src/zope/app/container/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/metaconfigure.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/container/browser/metaconfigure.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -72,7 +72,7 @@
if add is not None:
from zope.app.menus import zmi_actions
viewObj = view(_context, name='+', menu=zmi_actions,
- title=_('Add'), for_=(for_,), permission=add,
+ title=_('Add'), for_=for_, permission=add,
class_=Adding)
viewObj.page(_context, name='index.html', attribute='index')
viewObj.page(_context, name='action.html', attribute='action')
Modified: Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -90,12 +90,12 @@
<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
'contents.html',
<InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>,
- <InterfaceClass zope.publisher.interfaces.browser.IDefaultLayer>),
+ <InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<function handler>,
('Adapters',
'register',
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
- <InterfaceClass zope.publisher.interfaces.browser.IDefaultLayer>),
+ <InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.interface.Interface>,
'contents.html',
<class 'zope.app.publisher.browser.viewmeta.Contents'>,
@@ -108,12 +108,12 @@
<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
'index.html',
<InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>,
- <InterfaceClass zope.publisher.interfaces.browser.IDefaultLayer>),
+ <InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<function handler>,
('Adapters',
'register',
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
- <InterfaceClass zope.publisher.interfaces.browser.IDefaultLayer>),
+ <InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.interface.Interface>,
'index.html',
<class 'zope.app.publisher.browser.viewmeta.Contents'>,
@@ -152,14 +152,14 @@
('', <InterfaceClass zope.interface.Interface>)),
(('view',
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
- <InterfaceClass zope.publisher.interfaces.browser.IDefaultLayer>),
+ <InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
'+',
<InterfaceClass zope.interface.Interface>),
<function handler>,
('Adapters',
'register',
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
- <InterfaceClass zope.publisher.interfaces.browser.IDefaultLayer>),
+ <InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.interface.Interface>,
'+',
<class 'zope.app.publisher.browser.viewmeta.+'>,
Modified: Zope3/trunk/src/zope/app/form/browser/add.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/add.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/form/browser/add.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -29,7 +29,7 @@
from zope.app.form.interfaces import IInputWidget, WidgetsError
from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.publisher.interfaces.browser import IDefaultLayer
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.schema.interfaces import ValidationError
from zope.security.checker import defineChecker, NamesChecker
from editview import EditView
@@ -165,7 +165,7 @@
)
)
if layer is None:
- layer = IDefaultLayer
+ layer = IDefaultBrowserLayer
s = zapi.getGlobalService(zapi.servicenames.Adapters)
s.register((for_, layer), Interface, name, class_)
Modified: Zope3/trunk/src/zope/app/form/browser/addwizard.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/addwizard.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/form/browser/addwizard.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -26,7 +26,7 @@
from zope.app.form.interfaces import WidgetsError, IInputWidget
from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.publisher.interfaces.browser import IDefaultLayer
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.schema.interfaces import ValidationError
from zope.security.checker import defineChecker, NamesChecker
from editwizard import EditWizardView, WizardStorage
@@ -135,7 +135,7 @@
)
)
if layer is None:
- layer = IDefaultLayer
+ layer = IDefaultBrowserLayer
s = zapi.getGlobalService(zapi.servicenames.Adapter)
s.register((for_, layer), Interface, name, class_)
Modified: Zope3/trunk/src/zope/app/form/browser/editview.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/editview.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/form/browser/editview.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -22,7 +22,7 @@
from zope.interface import Interface
from zope.schema import getFieldNamesInOrder
-from zope.publisher.interfaces.browser import IDefaultLayer
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.security.checker import defineChecker, NamesChecker
from zope.app import zapi
@@ -147,7 +147,7 @@
"browserDefault", "publishTraverse"),
permission))
if layer is None:
- layer = IDefaultLayer
+ layer = IDefaultBrowserLayer
s = zapi.getGlobalService(zapi.servicenames.Adapters)
s.register((for_, layer), Interface, name, class_)
Modified: Zope3/trunk/src/zope/app/form/browser/editwizard.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/editwizard.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/form/browser/editwizard.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -17,7 +17,7 @@
"""
__docformat__ = 'restructuredtext'
-from zope.publisher.interfaces.browser import IDefaultLayer
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.security.checker import defineChecker, NamesChecker
from zope.app import zapi
@@ -231,7 +231,7 @@
)
if layer is None:
- layer = IDefaultLayer
+ layer = IDefaultBrowserLayer
s = zapi.getGlobalService(zapi.servicenames.Adapter)
s.register((for_, layer), Interface, name, class_)
Modified: Zope3/trunk/src/zope/app/form/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/metaconfigure.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/form/browser/metaconfigure.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -27,7 +27,7 @@
from zope.schema import getFieldNamesInOrder
from zope.app.container.interfaces import IAdding
from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.publisher.interfaces.browser import IDefaultLayer
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.app.publisher.browser.menu import menuItemDirective
from zope.app.form import CustomWidgetFactory
@@ -46,7 +46,7 @@
# default basic information
for_ = None
- layer = IDefaultLayer
+ layer = IDefaultBrowserLayer
permission = 'zope.Public'
template = None
class_ = None
Modified: Zope3/trunk/src/zope/app/form/browser/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/metadirectives.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/form/browser/metadirectives.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -21,8 +21,9 @@
from zope.configuration.fields import GlobalObject, Tokens, Path, \
Bool, PythonIdentifier, MessageID
from zope.schema import Text, TextLine, Id
+from zope.app.component.fields import LayerField
from zope.app.security.fields import Permission
-from zope.app.publisher.browser.fields import MenuField, LayerField
+from zope.app.publisher.browser.fields import MenuField
class ICommonInformation(Interface):
"""
Modified: Zope3/trunk/src/zope/app/form/browser/schemadisplay.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/schemadisplay.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/form/browser/schemadisplay.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -18,7 +18,7 @@
__docformat__ = 'restructuredtext'
from zope.interface import Interface
-from zope.publisher.interfaces.browser import IDefaultLayer
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.schema import getFieldNamesInOrder
from zope.security.checker import defineChecker, NamesChecker
@@ -90,7 +90,7 @@
permission))
if layer is None:
- layer = IDefaultLayer
+ layer = IDefaultBrowserLayer
s = zapi.getGlobalService(zapi.servicenames.Adapters)
s.register((for_, layer), Interface, name, class_)
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_add.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_add.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_add.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -19,7 +19,8 @@
from zope.app.tests import ztapi
from zope.interface import Interface, implements
-from zope.publisher.interfaces.browser import IBrowserRequest, IDefaultLayer
+from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.publisher.browser import TestRequest
from zope.schema import TextLine, accessors
from zope.component import getView
@@ -156,7 +157,7 @@
self.assertEqual(descriminator,
('view', IAdding, 'addthis', IBrowserRequest,
- IDefaultLayer))
+ IDefaultBrowserLayer))
self.assertEqual(callable, AddViewFactory)
@@ -169,7 +170,7 @@
self.assertEqual(schema, I)
self.assertEqual(label, 'Add this')
self.assertEqual(permission, 'zope.Public')
- self.assertEqual(layer, IDefaultLayer)
+ self.assertEqual(layer, IDefaultBrowserLayer)
self.assertEqual(template, 'add.pt')
self.assertEqual(default_template, 'add.pt')
self.assertEqual(bases, (V, AddView, ))
Modified: Zope3/trunk/src/zope/app/pagelet/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/pagelet/metaconfigure.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/pagelet/metaconfigure.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -13,7 +13,7 @@
##############################################################################
"""Pagelet metadconfigure
-$Id:$
+$Id$
"""
__docformat__ = 'restructuredtext'
@@ -28,7 +28,7 @@
from zope.configuration.exceptions import ConfigurationError
-from zope.publisher.interfaces.browser import IDefaultLayer
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.app import zapi
from zope.app.component.metaconfigure import handler
@@ -84,7 +84,7 @@
def pagelet(_context, name, slot, permission, for_=Interface,
- layer=IDefaultLayer, view=IView, weight=0, template=None):
+ layer=IDefaultBrowserLayer, view=IView, weight=0, template=None):
required = {}
Modified: Zope3/trunk/src/zope/app/pagelet/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/pagelet/metadirectives.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/pagelet/metadirectives.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -13,7 +13,7 @@
##############################################################################
"""Pagelet metadirective
-$Id:$
+$Id$
"""
__docformat__ = 'restructuredtext'
@@ -23,9 +23,8 @@
from zope.schema import Int
from zope.app.security.fields import Permission
+from zope.app.component.fields import LayerField
-from zope.app.publisher.browser.fields import LayerField
-
from zope.configuration.fields import GlobalObject
Modified: Zope3/trunk/src/zope/app/pagelet/tales.py
===================================================================
--- Zope3/trunk/src/zope/app/pagelet/tales.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/pagelet/tales.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -13,7 +13,7 @@
##############################################################################
"""Pagelet tales expression registrations
-$Id:$
+$Id$
"""
__docformat__ = 'restructuredtext'
@@ -56,7 +56,7 @@
>>> from zope.interface import Interface
>>> from zope.security.checker import defineChecker
>>> from zope.publisher.browser import TestRequest
- >>> from zope.publisher.interfaces.browser import IDefaultLayer
+ >>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
>>> from zope.component.interfaces import IView
>>> from zope.app.publisher.browser import BrowserView
>>> from zope.app.pagelet.interfaces import IPagelet
@@ -74,7 +74,7 @@
>>> defineChecker(pagelet_factory, testChecker)
>>> adaptersrv = zope.component.getService('Adapters')
>>> adaptersrv.register(
- ... (Interface, IDefaultLayer, IView, IPageletSlot)
+ ... (Interface, IDefaultBrowserLayer, IView, IPageletSlot)
... , IPagelet, name, pagelet_factory)
Register slot interface:
@@ -87,7 +87,7 @@
>>> from zope.app.pagelet.collector import MacrosCollector
>>> collector_factory = MacrosCollector
>>> adaptersrv.register(
- ... (Interface, IDefaultLayer, IView, IPageletSlot)
+ ... (Interface, IDefaultBrowserLayer, IView, IPageletSlot)
... , IMacrosCollector, '', collector_factory)
Register pagelets expression:
@@ -181,7 +181,7 @@
>>> from zope.interface import Interface
>>> from zope.security.checker import defineChecker
>>> from zope.publisher.browser import TestRequest
- >>> from zope.publisher.interfaces.browser import IDefaultLayer
+ >>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
>>> from zope.component.interfaces import IView
>>> from zope.app.publisher.browser import BrowserView
>>> from zope.app.pagelet.interfaces import IPagelet
@@ -199,7 +199,7 @@
>>> defineChecker(pagelet_factory, testChecker)
>>> adaptersrv = zope.component.getService('Adapters')
>>> adaptersrv.register(
- ... (Interface, IDefaultLayer, IView, IPageletSlot)
+ ... (Interface, IDefaultBrowserLayer, IView, IPageletSlot)
... , IPagelet, name, pagelet_factory)
Register slot interface:
@@ -212,7 +212,7 @@
>>> from zope.app.pagelet.collector import MacroCollector
>>> collector_factory = MacroCollector
>>> adaptersrv.register(
- ... (Interface, IDefaultLayer, IView, IPageletSlot)
+ ... (Interface, IDefaultBrowserLayer, IView, IPageletSlot)
... , IMacroCollector, '', collector_factory)
Register pagelets expression:
@@ -318,7 +318,7 @@
>>> from zope.interface import Interface
>>> from zope.security.checker import defineChecker
>>> from zope.publisher.browser import TestRequest
- >>> from zope.publisher.interfaces.browser import IDefaultLayer
+ >>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
>>> from zope.component.interfaces import IView
>>> from zope.app.publisher.browser import BrowserView
>>> from zope.app.pagelet.interfaces import IPageletSlot
@@ -334,7 +334,7 @@
>>> defineChecker(factory, testChecker)
>>> adaptersrv = zope.component.getService('Adapters')
>>> adaptersrv.register(
- ... (Interface, IDefaultLayer, IView)
+ ... (Interface, IDefaultBrowserLayer, IView)
... , IPageData, '', factory)
Register slot interface:
@@ -347,7 +347,7 @@
>>> from zope.app.pagelet.collector import MacroCollector
>>> collector_factory = MacroCollector
>>> adaptersrv.register(
- ... (Interface, IDefaultLayer, IView, IPageletSlot)
+ ... (Interface, IDefaultBrowserLayer, IView, IPageletSlot)
... , IMacroCollector, '', collector_factory)
Register pagedata expression:
Modified: Zope3/trunk/src/zope/app/publication/httpfactory.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/httpfactory.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/publication/httpfactory.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -21,7 +21,8 @@
from zope.interface import directlyProvides, directlyProvidedBy
from zope.publisher.http import HTTPRequest
from zope.publisher.browser import BrowserRequest
-from zope.publisher.interfaces.browser import IDefaultSkin, IDefaultLayer
+from zope.publisher.interfaces.browser import IDefaultSkin
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.publisher.xmlrpc import XMLRPCRequest
from zope.app import zapi
@@ -60,7 +61,7 @@
if skin is not None:
directlyProvides(request, directlyProvidedBy(request)+skin)
else:
- directlyProvides(request, IDefaultLayer)
+ directlyProvides(request, IDefaultBrowserLayer)
else:
request = HTTPRequest(input_stream, output_steam, env)
request.setPublication(self._http)
Modified: Zope3/trunk/src/zope/app/publisher/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/configure.zcml 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/publisher/browser/configure.zcml 2004-11-09 00:44:51 UTC (rev 28407)
@@ -2,9 +2,13 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">
+<defaultLayer
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ layer="zope.publisher.interfaces.browser.IDefaultBrowserLayer" />
+
<browser:layer name="default"
- interface="zope.publisher.interfaces.browser.IDefaultLayer" />
-
+ interface="zope.publisher.interfaces.browser.IDefaultBrowserLayer" />
+
<content class="zope.publisher.browser.BrowserRequest">
<allow
interface="zope.publisher.interfaces.browser.IBrowserApplicationRequest"
Modified: Zope3/trunk/src/zope/app/publisher/browser/fields.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/fields.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/publisher/browser/fields.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -22,103 +22,11 @@
from zope.configuration.exceptions import ConfigurationError
from zope.configuration.fields import GlobalObject
from zope.interface.interfaces import IInterface
-from zope.publisher.interfaces.browser import ILayer
+from zope.app.publisher.interfaces.browser import IMenuItemType
from zope.app import zapi
-from zope.app.publisher.interfaces.browser import IMenuItemType
-class LayerField(GlobalObject):
- r"""This fields represents a layer.
-
- Besides being able to look up the layer by importing it, we also try
- to look up the name in the utility service.
-
- >>> from zope.interface import directlyProvides
- >>> from zope.interface.interface import InterfaceClass
-
- >>> layer1 = InterfaceClass('layer1', (),
- ... __doc__='Layer: layer1',
- ... __module__='zope.app.layers')
- >>> directlyProvides(layer1, ILayer)
-
- >>> layers = None
- >>> class Resolver(object):
- ... def resolve(self, path):
- ... if '..' in path:
- ... raise ValueError('Empty module name')
- ... if (path.startswith('zope.app.layers') and
- ... hasattr(layers, 'layer1') or
- ... path == 'zope.app.component.fields.layer1' or
- ... path == '.fields.layer1'):
- ... return layer1
- ... raise ConfigurationError, 'layer1'
-
- >>> field = LayerField()
- >>> field = field.bind(Resolver())
-
- Test 1: Import the layer
- ------------------------
-
- >>> field.fromUnicode('zope.app.component.fields.layer1') is layer1
- True
-
- Test 2: We have a shortcut name. Import the layer from `zope.app.layers`.
- -------------------------------------------------------------------------
-
- >>> from types import ModuleType as module
- >>> import sys
- >>> layers = module('layers')
- >>> old = sys.modules.get('zope.app.layers', None)
- >>> sys.modules['zope.app.layers'] = layers
- >>> setattr(layers, 'layer1', layer1)
-
- >>> field.fromUnicode('layer1') is layer1
- True
-
- >>> if old is not None:
- ... sys.modules['zope.app.layers'] = old
-
- Test 3: Get the layer from the utility service
- ----------------------------------------------
-
- >>> from zope.app.tests import ztapi
- >>> ztapi.provideUtility(ILayer, layer1, 'layer1')
-
- >>> field.fromUnicode('layer1') is layer1
- True
-
- Test 4: Import the layer by using a short name
- ----------------------------------------------
-
- >>> field.fromUnicode('.fields.layer1') is layer1
- True
- """
-
- def fromUnicode(self, u):
- name = str(u.strip())
-
- try:
- value = zapi.queryUtility(ILayer, name)
- except ComponentLookupError:
- # The component architecture is not up and running.
- pass
- else:
- if value is not None:
- return value
-
- try:
- value = self.context.resolve('zope.app.layers.'+name)
- except (ConfigurationError, ValueError), v:
- try:
- value = self.context.resolve(name)
- except ConfigurationError, v:
- raise zope.schema.ValidationError(v)
-
- self.validate(value)
- return value
-
-
class MenuField(GlobalObject):
r"""This fields represents a menu (item type).
Modified: Zope3/trunk/src/zope/app/publisher/browser/i18nresourcemeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/i18nresourcemeta.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/publisher/browser/i18nresourcemeta.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -17,7 +17,8 @@
"""
from zope.configuration.exceptions import ConfigurationError
from zope.interface import Interface
-from zope.publisher.interfaces.browser import IBrowserRequest, IDefaultLayer
+from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.security.proxy import Proxy
from zope.security.checker import CheckerPublic, Checker
@@ -34,7 +35,7 @@
default_allowed_attributes = '__call__'
def __init__(self, _context, name=None, defaultLanguage='en',
- layer=IDefaultLayer, permission=None):
+ layer=IDefaultBrowserLayer, permission=None):
self._context = _context
self.name = name
self.defaultLanguage = defaultLanguage
Modified: Zope3/trunk/src/zope/app/publisher/browser/icon.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/icon.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/publisher/browser/icon.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -19,7 +19,7 @@
import re
from zope.interface import Interface
-from zope.publisher.interfaces.browser import IDefaultLayer
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.configuration.exceptions import ConfigurationError
from zope.app import zapi
@@ -62,7 +62,7 @@
return IconView(context, request, self.rname, self.alt)
def IconDirective(_context, name, for_, file=None, resource=None,
- layer=IDefaultLayer, alt=None):
+ layer=IDefaultBrowserLayer, alt=None):
iname = for_.getName()
Modified: Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -62,7 +62,7 @@
>>> iface.getName()
u'layer1'
>>> iface.__bases__
- (<InterfaceClass zope.publisher.interfaces.browser.ILayer>,)
+ (<InterfaceClass zope.publisher.interfaces.ILayer>,)
>>> hasattr(sys.modules['zope.app.layers'], 'layer1')
True
Modified: Zope3/trunk/src/zope/app/publisher/browser/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/metadirectives.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/publisher/browser/metadirectives.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -23,11 +23,10 @@
from zope.schema import TextLine, Text, Id, Int
from zope.app.component.metadirectives import IBasicViewInformation
-from zope.app.publisher.browser.fields import MenuField, LayerField
+from zope.app.component.fields import LayerField
+from zope.app.publisher.browser.fields import MenuField
from zope.app.security.fields import Permission
-from zope.app.i18n import ZopeMessageIDFactory as _
-
#
# browser views
#
@@ -46,15 +45,6 @@
required=False
)
- layer = LayerField(
- title=_("The layer the view is in."),
- description=_("""
- 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'."""),
- required=False,
- )
-
permission = Permission(
title=u"Permission",
description=u"The permission needed to use the view.",
@@ -69,11 +59,9 @@
traversing to the view name and then traversing to the page name.
"""
- for_ = Tokens(
- title=_("Specifications of the objects to be viewed"),
- description=_("This should be a list of interfaces or classes"),
- required=False,
- value_type=GlobalObject(missing_value=object(),),
+ for_ = GlobalObject(
+ title=u"The interface this view is for.",
+ required=False
)
name = TextLine(
Modified: Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -20,7 +20,7 @@
from zope.configuration.exceptions import ConfigurationError
from zope.interface import Interface
from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.publisher.interfaces.browser import IDefaultLayer
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.security.checker import CheckerPublic, NamesChecker
from zope.app import zapi
@@ -33,8 +33,8 @@
allowed_names = ('GET', 'HEAD', 'publishTraverse', 'browserDefault',
'request', '__call__')
-def resource(_context, name, layer=IDefaultLayer, permission='zope.Public',
- file=None, image=None, template=None):
+def resource(_context, name, layer=IDefaultBrowserLayer,
+ permission='zope.Public', file=None, image=None, template=None):
if permission == 'zope.Public':
permission = CheckerPublic
@@ -62,7 +62,7 @@
(layer,), Interface, name, factory, _context.info),
)
-def resourceDirectory(_context, name, directory, layer=IDefaultLayer,
+def resourceDirectory(_context, name, directory, layer=IDefaultBrowserLayer,
permission='zope.Public'):
if permission == 'zope.Public':
permission = CheckerPublic
Modified: Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -26,7 +26,7 @@
from zope.configuration.exceptions import ConfigurationError
from zope.app.component.interface import provideInterface
from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.publisher.interfaces.browser import IDefaultLayer
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.app import zapi
from zope.app.component.metaconfigure import handler
@@ -89,13 +89,12 @@
# page
def page(_context, name, permission, for_,
- layer=IDefaultLayer, template=None, class_=None,
+ layer=IDefaultBrowserLayer, template=None, class_=None,
allowed_interface=None, allowed_attributes=None,
attribute='__call__', menu=None, title=None,
):
- _handle_menu(_context, menu, title, for_, name, permission)
-
+ _handle_menu(_context, menu, title, [for_], name, permission)
required = {}
permission = _handle_permission(_context, permission)
@@ -177,7 +176,7 @@
class pages(object):
def __init__(self, _context, for_, permission,
- layer=IDefaultLayer, class_=None,
+ layer=IDefaultBrowserLayer, class_=None,
allowed_interface=None, allowed_attributes=None,
):
self.opts = dict(for_=for_, permission=permission,
@@ -208,23 +207,12 @@
default = None
def __init__(self, _context, for_, permission,
- name='', layer=IDefaultLayer, class_=None,
+ name='', layer=IDefaultBrowserLayer, class_=None,
allowed_interface=None, allowed_attributes=None,
menu=None, title=None, provides=Interface,
):
- if not isinstance(for_, (list, tuple)):
- import warnings
- # BBB This can go away in 3.3
- import pdb;pdb.set_trace()
- warnings.warn(
- "The for_ argument to "
- "zope.app.publisher.browser.metaconfigure.view should be a "
- "sequence of interfaces.",
- DeprecationWarning)
- for_ = (for_,)
- for_ = tuple(for_)
- _handle_menu(_context, menu, title, for_[0], name, permission)
+ _handle_menu(_context, menu, title, [for_], name, permission)
permission = _handle_permission(_context, permission)
@@ -337,8 +325,7 @@
required)
_handle_allowed_attributes(_context, allowed_interface, permission,
required)
- for iface in for_:
- _handle_for(_context, iface)
+ _handle_for(_context, for_)
defineChecker(newclass, Checker(required))
@@ -349,16 +336,16 @@
args = ('', self.provides)
)
- required = for_ + (layer,)
_context.action(
- discriminator = ('view', required, name, self.provides),
+ discriminator = ('view', (for_, layer), name, self.provides),
callable = handler,
- args = (zapi.servicenames.Adapters, 'register', required,
- self.provides, name, newclass, _context.info),
+ args = (zapi.servicenames.Adapters, 'register',
+ (for_, layer), self.provides, name, newclass,
+ _context.info),
)
def addview(_context, name, permission,
- layer=IDefaultLayer, class_=None,
+ layer=IDefaultBrowserLayer, class_=None,
allowed_interface=None, allowed_attributes=None,
menu=None, title=None
):
@@ -393,10 +380,13 @@
if not (menu and title):
raise ConfigurationError(
"If either menu or title are specified, they must "
- "both be specified.")
-
+ "both be specified.")
+ if len(for_) != 1:
+ raise ConfigurationError(
+ "Menus can be specified only for single-view, not for "
+ "multi-views.")
return menuItemDirective(
- _context, menu, for_, '@@' + name, title,
+ _context, menu, for_[0], '@@' + name, title,
permission=permission)
return []
Modified: Zope3/trunk/src/zope/app/rotterdam/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/__init__.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/rotterdam/__init__.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -17,12 +17,12 @@
"""
__docformat__ = "reStructuredText"
-from zope.publisher.interfaces.browser import ILayer, IDefaultLayer
+from zope.publisher.interfaces.browser import ILayer, IDefaultBrowserLayer
class rotterdam(ILayer):
"""The `rotterdam` layer."""
-class Rotterdam(rotterdam, IDefaultLayer):
+class Rotterdam(rotterdam, IDefaultBrowserLayer):
"""The `Rotterdam` skin.
It is available via `++skin++zope.app.rotterdam.Rotterdam`.
Modified: Zope3/trunk/src/zope/app/site/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/site/browser/metaconfigure.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/site/browser/metaconfigure.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -51,7 +51,7 @@
'folder':folder,
'title':'Add %s Tool' % interface.getName()} )
- addView = complexView(_context, (ISiteManager,), permission, addName,
+ addView = complexView(_context, ISiteManager, permission, addName,
class_=class_)
addView.page(_context, 'index.html', 'index')
addView.page(_context, 'action.html', 'action')
@@ -81,7 +81,7 @@
(ServiceToolAdding,),
{'folder':folder} )
- addView = complexView(_context, (ISiteManager,), permission, addName,
+ addView = complexView(_context, ISiteManager, permission, addName,
class_=class_)
addView.page(_context, 'index.html', 'index')
addView.page(_context, 'action.html', 'action')
Modified: Zope3/trunk/src/zope/app/tests/functional.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/functional.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/tests/functional.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -51,7 +51,8 @@
from zope.app.publication.xmlrpc import XMLRPCPublication
from zope.app.publication.zopepublication import ZopePublication
from zope.app.publication.http import HTTPPublication
-from zope.publisher.interfaces.browser import IDefaultLayer, IDefaultSkin
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+from zope.publisher.interfaces.browser import IDefaultSkin
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.app.component.hooks import setSite, getSite
@@ -91,7 +92,7 @@
"""Returns the current default skin as an interface."""
adapters = zapi.getService(zapi.servicenames.Adapters)
skin = adapters.lookup((IBrowserRequest,), IDefaultSkin, '')
- return skin or IDefaultLayer
+ return skin or IDefaultBrowserLayer
grant_request = (r"""
Modified: Zope3/trunk/src/zope/app/tests/ztapi.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/ztapi.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/app/tests/ztapi.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -18,7 +18,7 @@
import zope.interface
from zope.component.interfaces import IDefaultViewName
from zope.publisher.browser import IBrowserRequest
-from zope.publisher.interfaces.browser import IDefaultLayer
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.app import zapi
from zope.app.traversing.interfaces import ITraversable
@@ -32,7 +32,7 @@
layer = type
provideAdapter(for_[0], providing, factory, name, tuple(for_[1:])+(layer,))
-def browserView(for_, name, factory, layer=IDefaultLayer,
+def browserView(for_, name, factory, layer=IDefaultBrowserLayer,
providing=zope.interface.Interface):
"""Define a global browser view
"""
@@ -40,13 +40,13 @@
raise ValueError("Factory cannot be a list or tuple")
provideAdapter(for_, providing, factory, name, (layer,))
-def browserViewProviding(for_, factory, providing, layer=IDefaultLayer):
+def browserViewProviding(for_, factory, providing, layer=IDefaultBrowserLayer):
"""Define a view providing a particular interface."""
if isinstance(factory, (list, tuple)):
raise ValueError("Factory cannot be a list or tuple")
return browserView(for_, '', factory, layer, providing)
-def browserResource(name, factory, layer=IDefaultLayer,
+def browserResource(name, factory, layer=IDefaultBrowserLayer,
providing=zope.interface.Interface):
"""Define a global browser view
"""
@@ -54,7 +54,8 @@
raise ValueError("Factory cannot be a list or tuple")
provideAdapter((layer,), providing, factory, name)
-def setDefaultViewName(for_, name, layer=IDefaultLayer, type=IBrowserRequest):
+def setDefaultViewName(for_, name, layer=IDefaultBrowserLayer,
+ type=IBrowserRequest):
if layer is None:
layer = type
s = zapi.getGlobalServices().getService(zapi.servicenames.Adapters)
Modified: Zope3/trunk/src/zope/publisher/browser.py
===================================================================
--- Zope3/trunk/src/zope/publisher/browser.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/publisher/browser.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -27,7 +27,8 @@
from zope.interface import implements, directlyProvides
from zope.i18n.interfaces import IUserPreferredLanguages
from zope.i18n.interfaces import IUserPreferredCharsets
-from zope.publisher.interfaces.browser import IBrowserRequest, IDefaultLayer
+from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.publisher.interfaces.browser import IBrowserApplicationRequest
from zope.publisher.http import HTTPRequest, HTTPResponse
@@ -625,7 +626,7 @@
if skin is not None:
directlyProvides(self, skin)
else:
- directlyProvides(self, IDefaultLayer)
+ directlyProvides(self, IDefaultBrowserLayer)
def setPrincipal(self, principal):
# HTTPRequest needs to notify the HTTPTask of the username.
Modified: Zope3/trunk/src/zope/publisher/interfaces/__init__.py
===================================================================
--- Zope3/trunk/src/zope/publisher/interfaces/__init__.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/publisher/interfaces/__init__.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -22,6 +22,7 @@
from zope.exceptions import NotFoundError, INotFoundError
from zope.component.interfaces import IPresentationRequest
from zope.interface import implements
+from zope.interface.interfaces import IInterface
from zope.interface.common.mapping import IEnumerableMapping
from zope.interface.common.interfaces import IException
from zope.security.interfaces import IParticipation
@@ -423,3 +424,7 @@
class IRequest(IPublisherRequest, IPublicationRequest, IApplicationRequest):
"""The basic request contract
"""
+
+class ILayer(IInterface):
+ """A grouping of related views for a request."""
+
Modified: Zope3/trunk/src/zope/publisher/interfaces/browser.py
===================================================================
--- Zope3/trunk/src/zope/publisher/interfaces/browser.py 2004-11-08 18:59:12 UTC (rev 28406)
+++ Zope3/trunk/src/zope/publisher/interfaces/browser.py 2004-11-09 00:44:51 UTC (rev 28407)
@@ -20,6 +20,7 @@
from zope.publisher.interfaces import IPublication
from zope.publisher.interfaces import IPublishTraverse
+from zope.publisher.interfaces import ILayer
from zope.publisher.interfaces.http import IHTTPApplicationRequest
from zope.publisher.interfaces.http import IHTTPRequest
@@ -104,11 +105,7 @@
"""
-class ILayer(IInterface):
- """A layer contains views of similar layout."""
-
-
-class IDefaultLayer(ILayer):
+class IDefaultBrowserLayer(ILayer):
"""The default layer."""
More information about the Zope3-Checkins
mailing list