diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-11-29 14:52:29 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-11-29 14:52:29 +0000 |
| commit | af9f2e5fd5664aeaea2057ce1c518fb04617a0f0 (patch) | |
| tree | d0ca3dbda2df89acc15b76ed6e5f7e34bbad90f0 /repoze | |
| parent | 7fb23b46b7b3fe3729d99166d13b96954b1de44a (diff) | |
| download | pyramid-af9f2e5fd5664aeaea2057ce1c518fb04617a0f0.tar.gz pyramid-af9f2e5fd5664aeaea2057ce1c518fb04617a0f0.tar.bz2 pyramid-af9f2e5fd5664aeaea2057ce1c518fb04617a0f0.zip | |
- Trying to use an HTTP method name string such as ``GET`` as a
``request_type`` predicate caused a startup time failure when it was
encountered in imperative configuration or in a decorator (symptom:
``Type Error: Required specification must be a specification``).
This now works again, although ``request_method`` is a more modern
predicate.
Diffstat (limited to 'repoze')
| -rw-r--r-- | repoze/bfg/configuration.py | 5 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_configuration.py | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/repoze/bfg/configuration.py b/repoze/bfg/configuration.py index c37ed2c72..4d7e8dd57 100644 --- a/repoze/bfg/configuration.py +++ b/repoze/bfg/configuration.py @@ -547,6 +547,11 @@ class Configurator(object): raise ConfigurationError('"view" was not specified and ' 'no "renderer" specified') + if request_type in ('GET', 'HEAD', 'PUT', 'POST', 'DELETE'): + # b/w compat for 1.0 + request_method = request_type + request_type = None + if request_type and route_name: raise ConfigurationError( 'A view cannot be configured with both the request_type and ' diff --git a/repoze/bfg/tests/test_configuration.py b/repoze/bfg/tests/test_configuration.py index 060f30e3a..416df3086 100644 --- a/repoze/bfg/tests/test_configuration.py +++ b/repoze/bfg/tests/test_configuration.py @@ -345,6 +345,19 @@ class ConfiguratorTests(unittest.TestCase): self.assertRaises(ConfigurationError, config.add_view, view, '', None, None, True, True) + def test_add_view_with_request_type_string(self): + view = lambda *arg: 'OK' + config = self._makeOne() + config.add_view(view=view, request_type='GET') + wrapper = self._getViewCallable(config) + request = DummyRequest() + request.method = 'POST' + self._assertNotFound(wrapper, None, request) + request = DummyRequest() + request.method = 'GET' + result = wrapper(None, request) + self.assertEqual(result, 'OK') + def test_add_view_view_callable_None_with_renderer(self): config = self._makeOne() self._registerRenderer(config, name='dummy') |
