diff options
author | Todd Willey <todd@ansolabs.com> | 2011-01-06 13:18:17 -0500 |
---|---|---|
committer | Todd Willey <todd@ansolabs.com> | 2011-01-06 13:18:17 -0500 |
commit | 963ece6feac200151b35df2efa0df4b1c75f1763 (patch) | |
tree | 3a3ca047e1f64e0a5b86ac8aad244ec1ac01637e | |
parent | bccec6c8bac90517a972a5eb8bb91a82b3a13065 (diff) | |
download | nova-963ece6feac200151b35df2efa0df4b1c75f1763.tar.gz nova-963ece6feac200151b35df2efa0df4b1c75f1763.tar.xz nova-963ece6feac200151b35df2efa0df4b1c75f1763.zip |
Add factories into the wsgi classes.
-rw-r--r-- | nova/wsgi.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/nova/wsgi.py b/nova/wsgi.py index b5d6b96c1..5ecc21eed 100644 --- a/nova/wsgi.py +++ b/nova/wsgi.py @@ -63,10 +63,20 @@ class Server(object): class Application(object): -# TODO(gundlach): I think we should toss this class, now that it has no -# purpose. """Base WSGI application wrapper. Subclasses need to implement __call__.""" + @classmethod + def factory(cls, global_config, **local_config): + """Used for paste app factories in paste.deploy config fles.""" + rv = cls() + for k,v in local_config.iteritems(): + if hasattr(rv, k): + setattr(rv, k, v) + else: + logging.debug(_("Unknown local config option %s for %s"), + k, cls) + return rv + def __call__(self, environ, start_response): r"""Subclasses will probably want to implement __call__ like this: @@ -111,6 +121,20 @@ class Middleware(Application): behavior. """ + @classmethod + def factory(cls, global_config, **local_config): + """Used for paste app factories in paste.deploy config fles.""" + def _factory(app): + rv = cls(app) + for k,v in local_config.iteritems(): + if hasattr(rv, k): + setattr(rv, k, v) + else: + logging.debug(_("Unknown local config option %s for %s"), + k, cls) + return rv + return _factory + def __init__(self, application): # pylint: disable-msg=W0231 self.application = application |