Add kwargs to WsgiMiddleware __init__

Add kwargs to this __init__ method is a way
to avoid some extra keyword arguments in local_conf [1].

    @classmethod
    def factory(cls, global_conf, **local_conf):
        def filter_(app):
            return cls(app, **local_conf)
        return filter_

These extra keyword arguments
can cause this exception (in case of ceilometer):
    `__init__() got an unexpected keyword argument`

[1] https://git.openstack.org/cgit/openstack/osprofiler/tree/osprofiler/web.py#n91

Change-Id: I82e0db75ef9f84075289e360428c09ec68fb72d9
This commit is contained in:
Tovin Seven 2017-06-16 15:22:37 +07:00
parent c91a493bda
commit 9986bababd
1 changed files with 5 additions and 1 deletions

View File

@ -69,7 +69,7 @@ def enable(hmac_keys=None):
class WsgiMiddleware(object):
"""WSGI Middleware that enables tracing for an application."""
def __init__(self, application, hmac_keys=None, enabled=False):
def __init__(self, application, hmac_keys=None, enabled=False, **kwargs):
"""Initialize middleware with api-paste.ini arguments.
:application: wsgi app
@ -79,6 +79,10 @@ class WsgiMiddleware(object):
by only those who knows this key which helps
avoid DDOS.
:enabled: This middleware can be turned off fully if enabled is False.
:kwargs: Other keyword arguments.
NOTE(tovin07): Currently, this `kwargs` is not used at all.
It's here to avoid some extra keyword arguments in local_conf
that cause `__init__() got an unexpected keyword argument`.
"""
self.application = application
self.name = "wsgi"