From c5d172481e1e95bf4c8811ec9d1b34f6792fa63a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 15 Dec 2010 15:50:21 -0500 Subject: - 1.0a5 introduced a bug when ``pyramid.config.Configurator.scan`` was used. The symptoms were: lots of deprecation warnings printed to the console about imports of deprecated Pyramid functions and classes and non-detection of views decorated with ``view_config`` decorators. This has now been fixed. Closes #68. --- CHANGES.txt | 9 +++++++++ pyramid/config.py | 2 +- pyramid/tests/selfscanapp/__init__.py | 11 +++++++++++ pyramid/tests/selfscanapp/another.py | 6 ++++++ pyramid/tests/test_integration.py | 20 ++++++++++++++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 pyramid/tests/selfscanapp/__init__.py create mode 100644 pyramid/tests/selfscanapp/another.py diff --git a/CHANGES.txt b/CHANGES.txt index 4e4b4f771..1e63e67e6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,15 @@ Next release ============ +Bug Fixes +--------- + +- 1.0a5 introduced a bug when ``pyramid.config.Configurator.scan`` was used. + The symptoms were: lots of deprecation warnings printed to the console + about imports of deprecated Pyramid functions and classes and non-detection + of views decorated with ``view_config`` decorators. This has now been + fixed. + 1.0a5 (2010-12-14) ================== diff --git a/pyramid/config.py b/pyramid/config.py index 1c6d1878c..58e2550da 100644 --- a/pyramid/config.py +++ b/pyramid/config.py @@ -1790,7 +1790,7 @@ class Configurator(object): self.registry.registerUtility(mapper, IRoutesMapper) return mapper - @action_method + # this is *not* an action method (uses caller_package) def scan(self, package=None, categories=None): """ Scan a Python package and any of its subpackages for objects marked with :term:`configuration decoration` such as diff --git a/pyramid/tests/selfscanapp/__init__.py b/pyramid/tests/selfscanapp/__init__.py new file mode 100644 index 000000000..779ea3eed --- /dev/null +++ b/pyramid/tests/selfscanapp/__init__.py @@ -0,0 +1,11 @@ +from pyramid.view import view_config + +@view_config(renderer='string') +def abc(request): + return 'root' + +def main(): + from pyramid.config import Configurator + c = Configurator() + c.scan() + return c diff --git a/pyramid/tests/selfscanapp/another.py b/pyramid/tests/selfscanapp/another.py new file mode 100644 index 000000000..a30ad3297 --- /dev/null +++ b/pyramid/tests/selfscanapp/another.py @@ -0,0 +1,6 @@ +from pyramid.view import view_config + +@view_config(name='two', renderer='string') +def two(request): + return 'two' + diff --git a/pyramid/tests/test_integration.py b/pyramid/tests/test_integration.py index 2c8892eef..971c4832e 100644 --- a/pyramid/tests/test_integration.py +++ b/pyramid/tests/test_integration.py @@ -267,6 +267,26 @@ class ImperativeIncludeConfigurationTest(unittest.TestCase): res = self.testapp.get('/three', status=200) self.failUnless('three' in res.body) +class SelfScanAppTest(unittest.TestCase): + def setUp(self): + from pyramid.tests.selfscanapp import main + config = main() + app = config.make_wsgi_app() + from webtest import TestApp + self.testapp = TestApp(app) + self.config = config + + def tearDown(self): + self.config.end() + + def test_root(self): + res = self.testapp.get('/', status=200) + self.failUnless('root' in res.body) + + def test_two(self): + res = self.testapp.get('/two', status=200) + self.failUnless('two' in res.body) + class DummyContext(object): pass -- cgit v1.2.3