diff options
| author | Chris McDonough <chrism@agendaless.com> | 2010-07-28 01:26:09 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2010-07-28 01:26:09 +0000 |
| commit | be6f3b9ae06b31920d90744b20ccb7a8b4d9a278 (patch) | |
| tree | 1b7b5831b1c80fb1057d0a1e73c4191825f622ab | |
| parent | d58946946d3b29c3de8a7b4d937aa4af72bf63bf (diff) | |
| download | pyramid-be6f3b9ae06b31920d90744b20ccb7a8b4d9a278.tar.gz pyramid-be6f3b9ae06b31920d90744b20ccb7a8b4d9a278.tar.bz2 pyramid-be6f3b9ae06b31920d90744b20ccb7a8b4d9a278.zip | |
- When adding a view for a route which did not yet exist ("did not yet
exist" meaning, temporally, a view was added with a route name for a
route which had not yet been added via add_route), the value of the
``custom_predicate`` argument to ``add_view`` was lost. Symptom:
wrong view matches when using URL dispatch and custom view
predicates together.
| -rw-r--r-- | CHANGES.txt | 8 | ||||
| -rw-r--r-- | repoze/bfg/configuration.py | 3 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_configuration.py | 11 |
3 files changed, 21 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 4185d9a65..6cb89f378 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,7 +7,15 @@ Features - The ``repoze.bfg.configuration.Configurator.add_route`` API now returns the route object that was added. +Bug Fixes +--------- +- When adding a view for a route which did not yet exist ("did not yet + exist" meaning, temporally, a view was added with a route name for a + route which had not yet been added via add_route), the value of the + ``custom_predicate`` argument to ``add_view`` was lost. Symptom: + wrong view matches when using URL dispatch and custom view + predicates together. 1.3a6 (2010-07-25) ================== diff --git a/repoze/bfg/configuration.py b/repoze/bfg/configuration.py index 08f6a6a5c..d11839613 100644 --- a/repoze/bfg/configuration.py +++ b/repoze/bfg/configuration.py @@ -839,7 +839,8 @@ class Configurator(object): containment=containment, attr=attr, renderer=renderer, wrapper=wrapper, xhr=xhr, accept=accept, header=header, path_info=path_info, - custom_predicates=(), context=context, _info=u'' + custom_predicates=custom_predicates, context=context, + _info=u'' ) view_info = deferred_views.setdefault(route_name, []) view_info.append(info) diff --git a/repoze/bfg/tests/test_configuration.py b/repoze/bfg/tests/test_configuration.py index a4a30c7e7..b34f6c270 100644 --- a/repoze/bfg/tests/test_configuration.py +++ b/repoze/bfg/tests/test_configuration.py @@ -1219,6 +1219,17 @@ class ConfiguratorTests(unittest.TestCase): self.failIfEqual(wrapper, None) self.assertEqual(wrapper(None, None), 'OK') + def test_deferred_route_views_retains_custom_predicates(self): + view = lambda *arg: 'OK' + config = self._makeOne() + config.add_view(view=view, route_name='foo', custom_predicates=('123',)) + self.assertEqual(len(config.registry.deferred_route_views), 1) + infos = config.registry.deferred_route_views['foo'] + self.assertEqual(len(infos), 1) + info = infos[0] + self.assertEqual(info['route_name'], 'foo') + self.assertEqual(info['custom_predicates'], ('123',)) + def test_add_view_with_route_name_exception(self): from zope.interface import implementedBy from zope.component import ComponentLookupError |
