Skip to content

Commit

Permalink
Deprecate the 'layer' argument of view and resource. They already had
Browse files Browse the repository at this point in the history
a 'type' argument that should be used now exclusively.
  • Loading branch information
philikon committed Feb 21, 2006
1 parent f3816e3 commit abb8ea1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
23 changes: 15 additions & 8 deletions metaconfigure.py
Expand Up @@ -17,13 +17,13 @@
"""
__docformat__ = 'restructuredtext'

import warnings
import zope.interface
from zope import component
from zope.component.interfaces import IDefaultViewName, IFactory
from zope.configuration.exceptions import ConfigurationError
import zope.interface
from zope.interface import Interface, providedBy
from zope.interface.interfaces import IInterface

from zope.proxy import ProxyBase, getProxiedObject

from zope.security.checker import InterfaceChecker, CheckerPublic
Expand Down Expand Up @@ -310,7 +310,6 @@ def resource(_context, factory, type, name, layer=None,
)

if permission:

checker = _checker(_context, permission,
allowed_interface, allowed_attributes)

Expand All @@ -319,14 +318,18 @@ def proxyResource(request, factory=factory, checker=checker):

factory = proxyResource

if layer is None:
layer = type
if layer is not None:
warnings.warn_explicit(
"The 'layer' argument of the 'resource' directive has been "
"deprecated. Use the 'type' argument instead.",
DeprecationWarning, _context.info.file, _context.info.line)
type = layer

_context.action(
discriminator = ('resource', name, layer, provides),
discriminator = ('resource', name, type, provides),
callable = handler,
args = ('provideAdapter',
(layer,), provides, name, factory, _context.info),
(type,), provides, name, factory, _context.info),
)
_context.action(
discriminator = None,
Expand Down Expand Up @@ -389,9 +392,13 @@ def factory(ob, request):
ob = f(ob)
return factories[-1](ob, request)

# if layer not specified, use default layer for type
# BBB 2006/02/18, to be removed after 12 months
if layer is not None:
for_ = for_ + (layer,)
warnings.warn_explicit(
"The 'layer' argument of the 'view' directive has been "
"deprecated. Use the 'type' argument instead.",
DeprecationWarning, _context.info.file, _context.info.line)
else:
for_ = for_ + (type,)

Expand Down
10 changes: 8 additions & 2 deletions metadirectives.py
Expand Up @@ -85,6 +85,7 @@ class IBasicViewInformation(zope.interface.Interface):
required=False,
)

# BBB 2006/02/18, to be removed after 12 months
layer = zope.app.component.fields.LayerField(
title=_("The layer the view is in."),
description=_("""
Expand Down Expand Up @@ -379,8 +380,11 @@ class IResourceDirective(IBasicComponentInformation,
IBasicResourceInformation):
"""Register a resource"""

# BBB 2006/02/18, to be removed after 12 months
layer = zope.app.component.fields.LayerField(
title=_("The layer the resource is in."),
title=_("The layer the resource is in. This argument has been "
"deprecated and will be removed in Zope 3.5. Use the "
"'type' argument instead."),
required=False,
)

Expand Down Expand Up @@ -518,7 +522,9 @@ class IFactorySubdirective(zope.interface.Interface):

# BBB: Deprecated. Will go away in 3.4.
class IDefaultLayerDirective(zope.interface.Interface):
"""Associate a default layer with a request type."""
"""Associate a default layer with a request type.
This directive has been deprecated and will go away in Zope 3.4."""

type = zope.configuration.fields.GlobalInterface(
title=_("Request type"),
Expand Down

0 comments on commit abb8ea1

Please sign in to comment.