diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-06-11 05:35:45 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-06-11 05:35:45 +0000 |
| commit | b57adfea3d136bc33367ae8aab4371810c9a9359 (patch) | |
| tree | 3396c052431a8597ac5104e493046e60384dd8bc | |
| parent | 2a258c73fccfea63592fe485a65bfca2aea83ef4 (diff) | |
| download | pyramid-b57adfea3d136bc33367ae8aab4371810c9a9359.tar.gz pyramid-b57adfea3d136bc33367ae8aab4371810c9a9359.tar.bz2 pyramid-b57adfea3d136bc33367ae8aab4371810c9a9359.zip | |
# provide backwards compatibility for applications which
# used routes (at least apps without any custom "context
# factory") in BFG 0.9.X and before
| -rw-r--r-- | repoze/bfg/router.py | 8 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_router.py | 20 |
2 files changed, 27 insertions, 1 deletions
diff --git a/repoze/bfg/router.py b/repoze/bfg/router.py index 670a6a05c..65044b6e1 100644 --- a/repoze/bfg/router.py +++ b/repoze/bfg/router.py @@ -392,4 +392,10 @@ class DefaultRootFactory: __parent__ = None __name__ = None def __init__(self, environ): - pass + if 'bfg.routes.matchdict' in environ: + # provide backwards compatibility for applications which + # used routes (at least apps without any custom "context + # factory") in BFG 0.9.X and before + self.__dict__.update(environ['bfg.routes.matchdict']) + + diff --git a/repoze/bfg/tests/test_router.py b/repoze/bfg/tests/test_router.py index 589843b0f..be4fbad59 100644 --- a/repoze/bfg/tests/test_router.py +++ b/repoze/bfg/tests/test_router.py @@ -876,6 +876,26 @@ class TestDefaultForbiddenView(unittest.TestCase): response = self._callFUT(context, request) self.failUnless('<code>abc&123</code>' in response.body) +class TestDefaultRootFactory(unittest.TestCase): + def _getTargetClass(self): + from repoze.bfg.router import DefaultRootFactory + return DefaultRootFactory + + def _makeOne(self, environ): + return self._getTargetClass()(environ) + + def test_no_matchdict(self): + environ = {} + root = self._makeOne(environ) + self.assertEqual(root.__parent__, None) + self.assertEqual(root.__name__, None) + + def test_matchdict(self): + environ = {'bfg.routes.matchdict':{'a':1, 'b':2}} + root = self._makeOne(environ) + self.assertEqual(root.a, 1) + self.assertEqual(root.b, 2) + class DummyRegistryManager: def push(self, registry): |
