Chris McDonough
2010-12-19 14b78b33fb6d875c41ab0f95f9d9796cc050d615
- 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).
6 files modified
45 ■■■■ changed files
CHANGES.txt 8 ●●●●● patch | view | raw | blame | history
pyramid/config.py 12 ●●●●● patch | view | raw | blame | history
pyramid/tests/test_config.py 21 ●●●●● patch | view | raw | blame | history
pyramid/tests/test_view.py 1 ●●●● patch | view | raw | blame | history
pyramid/view.py 1 ●●●● patch | view | raw | blame | history
setup.py 2 ●●● patch | view | raw | blame | history
CHANGES.txt
@@ -78,6 +78,9 @@
- 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 @@
- Added ``debug_routematch = false`` to all paster templates.
Dependencies
------------
- Depend on Venusian >= 0.5 (for scanning conflict exception decoration).
1.0a6 (2010-12-15)
==================
pyramid/config.py
@@ -109,11 +109,13 @@
    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)
pyramid/tests/test_config.py
@@ -3424,6 +3424,27 @@
        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:
pyramid/tests/test_view.py
@@ -481,6 +481,7 @@
class DummyVenusianInfo(object):
    scope = 'notaclass'
    module = sys.modules['pyramid.tests']
    codeinfo = 'codeinfo'
class DummyVenusian(object):
    def __init__(self, info=None):
pyramid/view.py
@@ -417,6 +417,7 @@
        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
setup.py
@@ -40,7 +40,7 @@
    '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',
    ]