[Checkins] SVN: zope.component/tseaver-test_cleanup/ Remove long-deprecated 'layer' arg. for 'view' and 'resource' directives.
Tres Seaver
cvs-admin at zope.org
Tue Jun 26 23:01:17 UTC 2012
Log message for revision 127118:
Remove long-deprecated 'layer' arg. for 'view' and 'resource' directives.
Changed:
_U zope.component/tseaver-test_cleanup/
U zope.component/tseaver-test_cleanup/CHANGES.txt
U zope.component/tseaver-test_cleanup/src/zope/component/tests/test_zcml.py
U zope.component/tseaver-test_cleanup/src/zope/component/zcml.py
-=-
Modified: zope.component/tseaver-test_cleanup/CHANGES.txt
===================================================================
--- zope.component/tseaver-test_cleanup/CHANGES.txt 2012-06-26 23:01:10 UTC (rev 127117)
+++ zope.component/tseaver-test_cleanup/CHANGES.txt 2012-06-26 23:01:14 UTC (rev 127118)
@@ -4,6 +4,10 @@
4.0.0 (unreleased)
==================
+- Removed the long-deprecated ``layer`` argument to the
+ ``zope.component.zcml.view`` and ``zope.component.zcml.resource``
+ ZCML directives.
+
- Added support for continuous integration using ``tox`` and ``jenkins``.
- Got tests to run using ``setup.py test``.
Modified: zope.component/tseaver-test_cleanup/src/zope/component/tests/test_zcml.py
===================================================================
--- zope.component/tseaver-test_cleanup/src/zope/component/tests/test_zcml.py 2012-06-26 23:01:10 UTC (rev 127117)
+++ zope.component/tseaver-test_cleanup/src/zope/component/tests/test_zcml.py 2012-06-26 23:01:14 UTC (rev 127118)
@@ -733,6 +733,75 @@
self.assertEqual(action['args'], ('foo', IFoo, IBar))
+class Test_view(unittest.TestCase):
+
+ def _callFUT(self, *args, **kw):
+ from zope.component.zcml import view
+ return view(*args, **kw)
+
+ def test_w_allowed_interface_wo_permission(self):
+ from zope.interface import Interface
+ from zope.component.zcml import ComponentConfigurationError
+ class IViewType(Interface):
+ pass
+ class IView(Interface):
+ def foo():
+ pass
+ def bar():
+ pass
+ class _View(object):
+ def foo():
+ pass
+ def bar():
+ pass
+ _cfg_ctx = _makeConfigContext()
+ self.assertRaises(ComponentConfigurationError,
+ self._callFUT, _cfg_ctx, _View, IViewType, 'test',
+ for_=(Interface, Interface),
+ allowed_interface=IView)
+
+ def test_w_allowed_attributes_wo_permission(self):
+ from zope.interface import Interface
+ from zope.component.zcml import ComponentConfigurationError
+ class IViewType(Interface):
+ pass
+ class _View(object):
+ def foo():
+ pass
+ def bar():
+ pass
+ _cfg_ctx = _makeConfigContext()
+ self.assertRaises(ComponentConfigurationError,
+ self._callFUT, _cfg_ctx, _View, IViewType, 'test',
+ for_=(Interface, Interface),
+ allowed_attributes=('foo', 'bar'))
+
+ def test_w_factory_as_None(self):
+ from zope.interface import Interface
+ from zope.component.zcml import ComponentConfigurationError
+ class IViewType(Interface):
+ pass
+ _cfg_ctx = _makeConfigContext()
+ self.assertRaises(ComponentConfigurationError,
+ self._callFUT, _cfg_ctx, None, IViewType, 'test',
+ for_=(Interface, Interface))
+
+ def test_w_for__as_empty(self):
+ from zope.interface import Interface
+ from zope.component.zcml import ComponentConfigurationError
+ class IViewType(Interface):
+ pass
+ class _View(object):
+ def foo():
+ pass
+ def bar():
+ pass
+ _cfg_ctx = _makeConfigContext()
+ self.assertRaises(ComponentConfigurationError,
+ self._callFUT, _cfg_ctx, _View, IViewType, 'test',
+ for_=())
+
+
class ResourceViewTests(PlacelessSetup, unittest.TestCase):
def setUp(self):
@@ -1199,5 +1268,6 @@
unittest.makeSuite(Test_subscriber),
unittest.makeSuite(Test_utility),
unittest.makeSuite(Test_interface),
+ unittest.makeSuite(Test_view),
unittest.makeSuite(ResourceViewTests),
))
Modified: zope.component/tseaver-test_cleanup/src/zope/component/zcml.py
===================================================================
--- zope.component/tseaver-test_cleanup/src/zope/component/zcml.py 2012-06-26 23:01:10 UTC (rev 127117)
+++ zope.component/tseaver-test_cleanup/src/zope/component/zcml.py 2012-06-26 23:01:14 UTC (rev 127118)
@@ -13,8 +13,6 @@
##############################################################################
"""Component Architecture configuration handlers
"""
-import warnings
-
from zope.configuration.exceptions import ConfigurationError
from zope.configuration.fields import Bool
from zope.configuration.fields import GlobalInterface
@@ -448,15 +446,6 @@
required=False,
)
- layer = GlobalInterface(
- 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,
- )
-
allowed_interface = Tokens(
title=_("Interface that is also allowed if user has permission."),
description=_("""
@@ -520,7 +509,6 @@
)
def view(_context, factory, type, name, for_,
- layer=None,
permission=None,
allowed_interface=None,
allowed_attributes=None,
@@ -574,18 +562,7 @@
ob = f(ob)
return factories[-1](ob, request)
- # 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. If you have "
- "an existing 'type' argument IBrowserRequest, replace it with the "
- "'layer' argument (the layer subclasses IBrowserRequest). "
- "which subclasses BrowserRequest.",
- DeprecationWarning, _context.info.file, _context.info.line)
- else:
- for_ = for_ + (type,)
+ for_ = for_ + (type,)
_context.action(
discriminator = ('view', for_, name, provides),
@@ -620,11 +597,6 @@
IBasicResourceInformation):
"""Register a resource"""
- layer = GlobalInterface(
- title=_("The layer the resource is in."),
- required=False,
- )
-
allowed_interface = Tokens(
title=_("Interface that is also allowed if user has permission."),
required=False,
@@ -638,7 +610,7 @@
value_type=PythonIdentifier(),
)
-def resource(_context, factory, type, name, layer=None,
+def resource(_context, factory, type, name,
permission=None,
allowed_interface=None, allowed_attributes=None,
provides=Interface):
@@ -660,13 +632,6 @@
factory = proxyResource
- 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, type, provides),
callable = handler,
More information about the checkins
mailing list