Optimize filter context

Just use a direct filter factory for ContextMiddleware

Change-Id: Ie17bb88c331bdb4354d0abb24346ab80f13cd323
Signed-off-by: Steven Dake <sdake@redhat.com>
This commit is contained in:
Steven Dake 2012-07-19 19:51:47 -07:00
parent 8ced477069
commit 06705da563
3 changed files with 17 additions and 7 deletions

View File

@ -60,8 +60,7 @@ paste.filter_factory = heat.common.wsgi:filter_factory
heat.filter_factory = heat.api.middleware.cache_manage:CacheManageFilter
[filter:context]
paste.filter_factory = heat.common.wsgi:filter_factory
heat.filter_factory = heat.common.context:ContextMiddleware
paste.filter_factory = heat.common.context:ContextMiddleware_filter_factory
[filter:ec2authtoken]
paste.filter_factory = heat.common.wsgi:filter_factory

View File

@ -12,5 +12,4 @@ paste.app_factory = heat.common.wsgi:app_factory
heat.app_factory = heat.metadata.api.v1:API
[filter:context]
paste.filter_factory = heat.common.wsgi:filter_factory
heat.filter_factory = heat.common.context:ContextMiddleware
paste.filter_factory = heat.common.context:ContextMiddleware_filter_factory

View File

@ -110,8 +110,7 @@ class ContextMiddleware(wsgi.Middleware):
]
def __init__(self, app, conf, **local_conf):
self.conf = conf
self.conf.register_opts(self.opts)
cfg.CONF.register_opts(self.opts)
# Determine the context class to use
self.ctxcls = RequestContext
@ -124,7 +123,7 @@ class ContextMiddleware(wsgi.Middleware):
"""
Create a context with the given arguments.
"""
kwargs.setdefault('owner_is_tenant', self.conf.owner_is_tenant)
kwargs.setdefault('owner_is_tenant', cfg.CONF.owner_is_tenant)
return self.ctxcls(*args, **kwargs)
@ -193,3 +192,16 @@ class ContextMiddleware(wsgi.Middleware):
service_password=service_password,
auth_url=auth_url, roles=roles,
is_admin=True)
def ContextMiddleware_filter_factory(global_conf, **local_conf):
"""
Factory method for paste.deploy
"""
conf = global_conf.copy()
conf.update(local_conf)
def filter(app):
return ContextMiddleware(app, conf)
return filter