diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-12-09 01:21:21 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-12-09 01:21:21 +0000 |
| commit | a294cdfef34cda587d288a457c9a2e7bf760e916 (patch) | |
| tree | a522d838a6e98832a5ed8bf934eabdbc07a3cd98 | |
| parent | 05d6f55437971a7059ea82e6fd3f6dedb4202ba5 (diff) | |
| download | pyramid-a294cdfef34cda587d288a457c9a2e7bf760e916.tar.gz pyramid-a294cdfef34cda587d288a457c9a2e7bf760e916.tar.bz2 pyramid-a294cdfef34cda587d288a457c9a2e7bf760e916.zip | |
- The exception class representing the error raised by various methods
of a ``Configurator`` is now importable as
``repoze.bfg.exceptions.ConfigurationError``.
| -rw-r--r-- | CHANGES.txt | 7 | ||||
| -rw-r--r-- | repoze/bfg/configuration.py | 6 | ||||
| -rw-r--r-- | repoze/bfg/exceptions.py | 5 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_configuration.py | 20 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_zcml.py | 4 | ||||
| -rw-r--r-- | repoze/bfg/zcml.py | 2 |
6 files changed, 28 insertions, 16 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 0ae688938..9150847f3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,13 @@ Next release ============ +Internals +--------- + +- The exception class representing the error raised by various methods + of a ``Configurator`` is now importable as + ``repoze.bfg.exceptions.ConfigurationError``. + Documentation ------------- diff --git a/repoze/bfg/configuration.py b/repoze/bfg/configuration.py index b858f405a..6cb4feb8d 100644 --- a/repoze/bfg/configuration.py +++ b/repoze/bfg/configuration.py @@ -6,7 +6,6 @@ import inspect from webob import Response -from zope.configuration.exceptions import ConfigurationError from zope.configuration import xmlconfig from zope.interface import Interface @@ -41,6 +40,7 @@ from repoze.bfg.compat import walk_packages from repoze.bfg.events import WSGIApplicationCreatedEvent from repoze.bfg.exceptions import Forbidden from repoze.bfg.exceptions import NotFound +from repoze.bfg.exceptions import ConfigurationError from repoze.bfg.log import make_stream_logger from repoze.bfg.path import caller_package from repoze.bfg.registry import Registry @@ -266,8 +266,8 @@ class Configurator(object): authorization = ACLAuthorizationPolicy() # default if authorization and not authentication: raise ConfigurationError( - 'If the "authorization" is passed a vallue, ' - 'the "authentication" argument musty also be ' + 'If the "authorization" is passed a value, ' + 'the "authentication" argument must also be ' 'passed a value; authorization requires authentication.') self._set_authentication_policy(authentication) self._set_authorization_policy(authorization) diff --git a/repoze/bfg/exceptions.py b/repoze/bfg/exceptions.py index afd617a2c..a5e4755f5 100644 --- a/repoze/bfg/exceptions.py +++ b/repoze/bfg/exceptions.py @@ -1,3 +1,5 @@ +from zope.configuration.exceptions import ConfigurationError as ZCE + class Forbidden(Exception): """\ Raise this exception within :term:`view` code to immediately @@ -22,3 +24,6 @@ class NotFound(Exception): into the WSGI environment under the ``repoze.bfg.message`` key, for availability to the Not Found view.""" +class ConfigurationError(ZCE): + """ Raised when inappropriate input values are supplied to an API + method of a :term:`Configurator`""" diff --git a/repoze/bfg/tests/test_configuration.py b/repoze/bfg/tests/test_configuration.py index 4523fe463..2e2283ab4 100644 --- a/repoze/bfg/tests/test_configuration.py +++ b/repoze/bfg/tests/test_configuration.py @@ -126,7 +126,7 @@ class ConfiguratorTests(unittest.TestCase): self.assertEqual(policy, result) def test_ctor_authorization_policy_only(self): - from zope.configuration.exceptions import ConfigurationError + from repoze.bfg.exceptions import ConfigurationError policy = object() self.assertRaises(ConfigurationError, self._makeOne, authorization_policy=policy) @@ -187,7 +187,7 @@ class ConfiguratorTests(unittest.TestCase): def test_setup_registry_authorization_policy_only(self): from repoze.bfg.registry import Registry - from zope.configuration.exceptions import ConfigurationError + from repoze.bfg.exceptions import ConfigurationError policy = object() reg = Registry() config = self._makeOne(reg) @@ -337,12 +337,12 @@ class ConfiguratorTests(unittest.TestCase): self.assertEqual(dummylock.released, True) def test_add_view_view_callable_None_no_renderer(self): - from zope.configuration.exceptions import ConfigurationError + from repoze.bfg.exceptions import ConfigurationError config = self._makeOne() self.assertRaises(ConfigurationError, config.add_view) def test_add_view_with_request_type_and_route_name(self): - from zope.configuration.exceptions import ConfigurationError + from repoze.bfg.exceptions import ConfigurationError config = self._makeOne() view = lambda *arg: 'OK' self.assertRaises(ConfigurationError, config.add_view, view, '', None, @@ -797,7 +797,7 @@ class ConfiguratorTests(unittest.TestCase): self._assertNotFound(wrapper, None, request) def test_add_view_with_header_badregex(self): - from zope.configuration.exceptions import ConfigurationError + from repoze.bfg.exceptions import ConfigurationError view = lambda *arg: 'OK' config = self._makeOne() self.assertRaises(ConfigurationError, @@ -876,7 +876,7 @@ class ConfiguratorTests(unittest.TestCase): self._assertNotFound(wrapper, context, None) def test_add_view_with_path_info_badregex(self): - from zope.configuration.exceptions import ConfigurationError + from repoze.bfg.exceptions import ConfigurationError view = lambda *arg: 'OK' config = self._makeOne() self.assertRaises(ConfigurationError, @@ -1229,7 +1229,7 @@ class ConfiguratorTests(unittest.TestCase): self.assertEqual(wrapped(None, request).__class__, StaticURLParser) def test__system_view_no_view_no_renderer(self): - from zope.configuration.exceptions import ConfigurationError + from repoze.bfg.exceptions import ConfigurationError config = self._makeOne() self.assertRaises(ConfigurationError, config._system_view, IDummy) @@ -1616,18 +1616,18 @@ class ConfiguratorTests(unittest.TestCase): self.assertRaises(ValueError, wrapped, None, request) def test_override_resource_samename(self): - from zope.configuration.exceptions import ConfigurationError + from repoze.bfg.exceptions import ConfigurationError config = self._makeOne() self.assertRaises(ConfigurationError, config.override_resource,'a', 'a') def test_override_resource_directory_with_file(self): - from zope.configuration.exceptions import ConfigurationError + from repoze.bfg.exceptions import ConfigurationError config = self._makeOne() self.assertRaises(ConfigurationError, config.override_resource, 'a:foo/', 'a:foo.pt') def test_override_resource_file_with_directory(self): - from zope.configuration.exceptions import ConfigurationError + from repoze.bfg.exceptions import ConfigurationError config = self._makeOne() self.assertRaises(ConfigurationError, config.override_resource, 'a:foo.pt', 'a:foo/') diff --git a/repoze/bfg/tests/test_zcml.py b/repoze/bfg/tests/test_zcml.py index 148b8cac6..f3e0ed80f 100644 --- a/repoze/bfg/tests/test_zcml.py +++ b/repoze/bfg/tests/test_zcml.py @@ -167,7 +167,7 @@ class TestSystemViewHandler(unittest.TestCase): def test_no_view_no_renderer(self): handler = self._makeOne(IDummy) - from zope.configuration.exceptions import ConfigurationError + from repoze.bfg.exceptions import ConfigurationError context = DummyContext() handler(context) actions = context.actions @@ -358,7 +358,7 @@ class TestAuthTktAuthenticationPolicyDirective(unittest.TestCase): self.assertEqual(policy.callback, callback) def test_it_configerror(self): - from zope.configuration.exceptions import ConfigurationError + from repoze.bfg.exceptions import ConfigurationError context = DummyContext() def callback(identity, request): """ """ diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py index 7e3130a7d..1d3ab2540 100644 --- a/repoze/bfg/zcml.py +++ b/repoze/bfg/zcml.py @@ -2,7 +2,6 @@ import os from zope.configuration import xmlconfig from zope.configuration.config import ConfigurationMachine -from zope.configuration.exceptions import ConfigurationError from zope.configuration.fields import GlobalInterface from zope.configuration.fields import GlobalObject from zope.configuration.fields import Tokens @@ -29,6 +28,7 @@ from repoze.bfg.authentication import RemoteUserAuthenticationPolicy from repoze.bfg.authentication import RepozeWho1AuthenticationPolicy from repoze.bfg.authorization import ACLAuthorizationPolicy from repoze.bfg.configuration import Configurator +from repoze.bfg.exceptions import ConfigurationError from repoze.bfg.path import package_path from repoze.bfg.request import route_request_iface from repoze.bfg.static import StaticRootFactory |
