diff options
| author | tosh <toshism@gmail.com> | 2017-06-26 19:03:45 -0500 |
|---|---|---|
| committer | tosh <toshism@gmail.com> | 2017-06-26 19:03:45 -0500 |
| commit | 4be1e6ccd46adc6c9515d68bee12965cfc7e285e (patch) | |
| tree | 9f1910b33dfa11fe2667bf60bae226e48b0b109f | |
| parent | ea593f9dd35df6892fa73061dda22fdf8a8a6055 (diff) | |
| download | pyramid-4be1e6ccd46adc6c9515d68bee12965cfc7e285e.tar.gz pyramid-4be1e6ccd46adc6c9515d68bee12965cfc7e285e.tar.bz2 pyramid-4be1e6ccd46adc6c9515d68bee12965cfc7e285e.zip | |
add support for custom category in view_config decorator
| -rw-r--r-- | pyramid/tests/test_view.py | 20 | ||||
| -rw-r--r-- | pyramid/view.py | 3 |
2 files changed, 22 insertions, 1 deletions
diff --git a/pyramid/tests/test_view.py b/pyramid/tests/test_view.py index e03487a70..43459947c 100644 --- a/pyramid/tests/test_view.py +++ b/pyramid/tests/test_view.py @@ -566,6 +566,26 @@ class TestViewConfigDecorator(unittest.TestCase): decorator(foo) self.assertEqual(venusian.depth, 2) + def test_call_withoutcategory(self): + decorator = self._makeOne() + venusian = DummyVenusian() + decorator.venusian = venusian + def foo(): pass + decorator(foo) + attachments = venusian.attachments + category = attachments[0][2] + self.assertEqual(category, 'pyramid') + + def test_call_withcategory(self): + decorator = self._makeOne(category='not_pyramid') + venusian = DummyVenusian() + decorator.venusian = venusian + def foo(): pass + decorator(foo) + attachments = venusian.attachments + category = attachments[0][2] + self.assertEqual(category, 'not_pyramid') + class Test_append_slash_notfound_view(BaseTest, unittest.TestCase): def _callFUT(self, context, request): from pyramid.view import append_slash_notfound_view diff --git a/pyramid/view.py b/pyramid/view.py index dc4aae3fa..a3f193011 100644 --- a/pyramid/view.py +++ b/pyramid/view.py @@ -215,12 +215,13 @@ class view_config(object): def __call__(self, wrapped): settings = self.__dict__.copy() depth = settings.pop('_depth', 0) + category = settings.pop('category', 'pyramid') def callback(context, name, ob): config = context.config.with_package(info.module) config.add_view(view=ob, **settings) - info = self.venusian.attach(wrapped, callback, category='pyramid', + info = self.venusian.attach(wrapped, callback, category=category, depth=depth + 1) if info.scope == 'class': |
