summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-12-19 01:19:50 -0500
committerChris McDonough <chrism@plope.com>2010-12-19 01:19:50 -0500
commit14b78b33fb6d875c41ab0f95f9d9796cc050d615 (patch)
treece1c35c6059640de8be7731c692dff9cd3429b5b
parente17964766e467dc926c6fc41afbef0add5e91aac (diff)
downloadpyramid-14b78b33fb6d875c41ab0f95f9d9796cc050d615.tar.gz
pyramid-14b78b33fb6d875c41ab0f95f9d9796cc050d615.tar.bz2
pyramid-14b78b33fb6d875c41ab0f95f9d9796cc050d615.zip
- When a configuration conflict is encountered during scanning, the conflict
exception now shows the decorator information that caused the conflict. - Depend on Venusian >= 0.5 (for scanning conflict exception decoration).
-rw-r--r--CHANGES.txt8
-rw-r--r--pyramid/config.py12
-rw-r--r--pyramid/tests/test_config.py21
-rw-r--r--pyramid/tests/test_view.py1
-rw-r--r--pyramid/view.py1
-rw-r--r--setup.py2
6 files changed, 39 insertions, 6 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index bdb7acd97..c1b441c50 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -78,6 +78,9 @@ Bug Fixes
- Make it possible to succesfully run all tests via ``nosetests`` command
directly (rather than indirectly via ``python setup.py nosetests``).
+- When a configuration conflict is encountered during scanning, the conflict
+ exception now shows the decorator information that caused the conflict.
+
Features
--------
@@ -109,6 +112,11 @@ Paster Templates
- Added ``debug_routematch = false`` to all paster templates.
+Dependencies
+------------
+
+- Depend on Venusian >= 0.5 (for scanning conflict exception decoration).
+
1.0a6 (2010-12-15)
==================
diff --git a/pyramid/config.py b/pyramid/config.py
index 59c8706d0..f3f8ff37b 100644
--- a/pyramid/config.py
+++ b/pyramid/config.py
@@ -109,11 +109,13 @@ def action_method(wrapped):
def wrapper(self, *arg, **kw):
if self._ainfo is None:
self._ainfo = []
- try:
- f = traceback.extract_stack(limit=3)
- info = f[-2]
- except: # pragma: no cover
- info = ''
+ info = kw.pop('_info', None)
+ if info is None:
+ try:
+ f = traceback.extract_stack(limit=3)
+ info = f[-2]
+ except: # pragma: no cover
+ info = ''
self._ainfo.append(info)
try:
result = wrapped(self, *arg, **kw)
diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py
index b6a04426c..e4ab9a867 100644
--- a/pyramid/tests/test_config.py
+++ b/pyramid/tests/test_config.py
@@ -3424,6 +3424,27 @@ class ConfiguratorTests(unittest.TestCase):
else: # pragma: no cover
raise AssertionError
+ def test_scan_conflict(self):
+ from zope.configuration.config import ConfigurationConflictError
+ from pyramid.tests import selfscanapp
+ from pyramid.config import Configurator
+ c = Configurator()
+ c.scan(selfscanapp)
+ c.scan(selfscanapp)
+ try:
+ c.commit()
+ except ConfigurationConflictError, why:
+ def scanconflicts(e):
+ conflicts = e._conflicts.values()
+ for conflict in conflicts:
+ for confinst in conflict:
+ yield confinst[3]
+ c1, c2, c3, c4 = scanconflicts(why)
+ self.assertEqual(c1, "@view_config(renderer='string')")
+ self.assertEqual(c2, "@view_config(renderer='string')")
+ self.assertEqual(c3, "@view_config(name='two', renderer='string')")
+ self.assertEqual(c4, "@view_config(name='two', renderer='string')")
+
def _conflictFunctions(self, e):
conflicts = e._conflicts.values()
for conflict in conflicts:
diff --git a/pyramid/tests/test_view.py b/pyramid/tests/test_view.py
index 64c2d9518..79e363756 100644
--- a/pyramid/tests/test_view.py
+++ b/pyramid/tests/test_view.py
@@ -481,6 +481,7 @@ class IContext(Interface):
class DummyVenusianInfo(object):
scope = 'notaclass'
module = sys.modules['pyramid.tests']
+ codeinfo = 'codeinfo'
class DummyVenusian(object):
def __init__(self, info=None):
diff --git a/pyramid/view.py b/pyramid/view.py
index cd313e5a8..67329c363 100644
--- a/pyramid/view.py
+++ b/pyramid/view.py
@@ -417,6 +417,7 @@ class view_config(object):
if renderer_name is not None and not isinstance(renderer_name, dict):
settings['renderer'] = {'name':renderer_name,
'package':info.module}
+ settings['_info'] = info.codeinfo
return wrapped
bfg_view = view_config # permanent b/c
diff --git a/setup.py b/setup.py
index 75f5b13dd..f698f06ae 100644
--- a/setup.py
+++ b/setup.py
@@ -40,7 +40,7 @@ install_requires=[
'zope.configuration',
'zope.deprecation',
'zope.interface >= 3.5.1', # 3.5.0 comment: "allow to bootstrap on jython"
- 'venusian >= 0.2',
+ 'venusian >= 0.5', # ``codeinfo``
'translationstring',
]