summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.rst3
-rw-r--r--src/pyramid/view.py3
-rw-r--r--tests/test_view.py11
3 files changed, 16 insertions, 1 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index afac078b0..5ebd0e81e 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -35,6 +35,9 @@ Features
provided by WebOb. This allows the attribute to now be settable.
See https://github.com/Pylons/pyramid/pull/3447
+- Improve debugging info from ``pyramid.view.view_config`` decorator.
+ See https://github.com/Pylons/pyramid/pull/3483
+
Deprecations
------------
diff --git a/src/pyramid/view.py b/src/pyramid/view.py
index 51e6c3c1b..b856c309a 100644
--- a/src/pyramid/view.py
+++ b/src/pyramid/view.py
@@ -220,7 +220,8 @@ class view_config(object):
self._get_info()
def _get_info(self):
- frameinfo = inspect.stack()[2]
+ depth = self.__dict__.get('_depth', 0)
+ frameinfo = inspect.stack()[depth + 2]
sourceline = frameinfo[4][0].strip()
self._info = frameinfo[1], frameinfo[2], frameinfo[3], sourceline
diff --git a/tests/test_view.py b/tests/test_view.py
index e182c28ad..5411e57c0 100644
--- a/tests/test_view.py
+++ b/tests/test_view.py
@@ -516,6 +516,17 @@ class TestViewConfigDecorator(unittest.TestCase):
self.assertEqual(info[2], 'test_create_info')
self.assertEqual(info[3], 'decorator = target()')
+ def test_create_info_depth(self):
+ target = self._getTargetClass()
+
+ def make():
+ return target(_depth=1)
+
+ decorator = make()
+ info = decorator._info
+ self.assertEqual(info[2], 'test_create_info_depth')
+ self.assertEqual(info[3], 'decorator = make()')
+
def test_create_context_trumps_for(self):
decorator = self._makeOne(context='123', for_='456')
self.assertEqual(decorator.context, '123')