diff --git a/swift/common/wsgi.py b/swift/common/wsgi.py index 19d5c689c8..3d775fd47a 100644 --- a/swift/common/wsgi.py +++ b/swift/common/wsgi.py @@ -16,7 +16,6 @@ """WSGI tools for use with swift.""" import errno -import inspect import os import signal import time @@ -234,26 +233,11 @@ class PipelineWrapper(object): return first_ctx.entry_point_name == entry_point_name def _format_for_display(self, ctx): - if ctx.entry_point_name: - return ctx.entry_point_name - elif inspect.isfunction(ctx.object): - # ctx.object is a reference to the actual filter_factory - # function, so we pretty-print that. It's not the nice short - # entry point, but it beats "". - # - # These happen when, instead of something like - # - # use = egg:swift#healthcheck - # - # you have something like this: - # - # paste.filter_factory = \ - # swift.common.middleware.healthcheck:filter_factory - return "%s:%s" % (inspect.getmodule(ctx.object).__name__, - ctx.object.__name__) - else: - # No idea what this is - return "" + # Contexts specified by pipeline= have .name set in NamedConfigLoader. + if hasattr(ctx, 'name'): + return ctx.name + # This should not happen: a foreign context. Let's not crash. + return "" def __str__(self): parts = [self._format_for_display(ctx) @@ -274,6 +258,7 @@ class PipelineWrapper(object): ctx = loadwsgi.loadcontext(loadwsgi.FILTER, spec, global_conf=self.context.global_conf) ctx.protocol = 'paste.filter_factory' + ctx.name = entry_point_name return ctx def index(self, entry_point_name): diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py index 425383aea6..fe5f75b22b 100644 --- a/test/unit/common/test_wsgi.py +++ b/test/unit/common/test_wsgi.py @@ -759,16 +759,14 @@ class TestPipelineWrapper(unittest.TestCase): def test_str(self): self.assertEqual( str(self.pipe), - "healthcheck catch_errors " + - "swift.common.middleware.tempurl:filter_factory proxy") + "healthcheck catch_errors tempurl proxy-server") def test_str_unknown_filter(self): - self.pipe.context.filter_contexts[0].entry_point_name = None + del self.pipe.context.filter_contexts[0].__dict__['name'] self.pipe.context.filter_contexts[0].object = 'mysterious' self.assertEqual( str(self.pipe), - " catch_errors " + - "swift.common.middleware.tempurl:filter_factory proxy") + " catch_errors tempurl proxy-server") class TestPipelineModification(unittest.TestCase):