diff options
author | Alvaro Lopez Garcia <aloga@ifca.unican.es> | 2013-06-24 11:08:48 +0200 |
---|---|---|
committer | Alvaro Lopez Garcia <aloga@ifca.unican.es> | 2013-07-09 13:26:22 +0200 |
commit | 8f1c5840d9eb65e4dfa48e54710d42b18dadd77e (patch) | |
tree | 63cabe9ca524a16d900f3b5b8be2151cdeeffd5b | |
parent | b556d8a6cad15b7dea0318c6164b10529969807d (diff) | |
download | keystone-8f1c5840d9eb65e4dfa48e54710d42b18dadd77e.tar.gz keystone-8f1c5840d9eb65e4dfa48e54710d42b18dadd77e.tar.xz keystone-8f1c5840d9eb65e4dfa48e54710d42b18dadd77e.zip |
wsgi.BaseApplication and wsgi.Router factories should use **kwargs
Also removed wrong references to nova in docstrings.
This is related with bug 1190978
Change-Id: I1b945596d4ebe39d03069b590b7f1a444eaef72f
-rw-r--r-- | keystone/common/wsgi.py | 22 | ||||
-rw-r--r-- | tests/test_wsgi.py | 21 |
2 files changed, 32 insertions, 11 deletions
diff --git a/keystone/common/wsgi.py b/keystone/common/wsgi.py index 91c28034..d22e61b9 100644 --- a/keystone/common/wsgi.py +++ b/keystone/common/wsgi.py @@ -103,18 +103,18 @@ class BaseApplication(object): [app:wadl] latest_version = 1.3 - paste.app_factory = nova.api.fancy_api:Wadl.factory + paste.app_factory = keystone.fancy_api:Wadl.factory which would result in a call to the `Wadl` class as - import nova.api.fancy_api - fancy_api.Wadl(latest_version='1.3') + import keystone.fancy_api + keystone.fancy_api.Wadl(latest_version='1.3') You could of course re-implement the `factory` method in subclasses, but using the kwarg passing it shouldn't be necessary. """ - return cls() + return cls(**local_config) def __call__(self, environ, start_response): r"""Subclasses will probably want to implement __call__ like this: @@ -276,12 +276,12 @@ class Middleware(Application): [filter:analytics] redis_host = 127.0.0.1 - paste.filter_factory = nova.api.analytics:Analytics.factory + paste.filter_factory = keystone.analytics:Analytics.factory which would result in a call to the `Analytics` class as - import nova.api.analytics - analytics.Analytics(app_from_paste, redis_host='127.0.0.1') + import keystone.analytics + keystone.analytics.Analytics(app, redis_host='127.0.0.1') You could of course re-implement the `factory` method in subclasses, but using the kwarg passing it shouldn't be necessary. @@ -486,12 +486,12 @@ class ExtensionRouter(Router): [filter:analytics] redis_host = 127.0.0.1 - paste.filter_factory = nova.api.analytics:Analytics.factory + paste.filter_factory = keystone.analytics:Analytics.factory which would result in a call to the `Analytics` class as - import nova.api.analytics - analytics.Analytics(app_from_paste, redis_host='127.0.0.1') + import keystone.analytics + keystone.analytics.Analytics(app, redis_host='127.0.0.1') You could of course re-implement the `factory` method in subclasses, but using the kwarg passing it shouldn't be necessary. @@ -500,7 +500,7 @@ class ExtensionRouter(Router): def _factory(app): conf = global_config.copy() conf.update(local_config) - return cls(app) + return cls(app, **local_config) return _factory diff --git a/tests/test_wsgi.py b/tests/test_wsgi.py index c73212c8..8ac594a8 100644 --- a/tests/test_wsgi.py +++ b/tests/test_wsgi.py @@ -125,6 +125,27 @@ class ApplicationTest(BaseWSGITest): self.assertEqual(resp.headers.get('Content-Length'), '0') self.assertEqual(resp.headers.get('Content-Type'), None) + def test_application_local_config(self): + class FakeApp(wsgi.Application): + def __init__(self, *args, **kwargs): + self.kwargs = kwargs + + app = FakeApp.factory({}, testkey="test") + self.assertIn("testkey", app.kwargs) + self.assertEquals("test", app.kwargs["testkey"]) + + +class ExtensionRouterTest(BaseWSGITest): + def test_extensionrouter_local_config(self): + class FakeRouter(wsgi.ExtensionRouter): + def __init__(self, *args, **kwargs): + self.kwargs = kwargs + + factory = FakeRouter.factory({}, testkey="test") + app = factory(self.app) + self.assertIn("testkey", app.kwargs) + self.assertEquals("test", app.kwargs["testkey"]) + class MiddlewareTest(BaseWSGITest): def test_middleware_request(self): |