diff options
| -rw-r--r-- | pyramid/config/views.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/pyramid/config/views.py b/pyramid/config/views.py index 1988b532b..b36bd1ca7 100644 --- a/pyramid/config/views.py +++ b/pyramid/config/views.py @@ -407,11 +407,15 @@ class DefaultViewMapper(object): mapped_view = self.map_nonclass_requestonly(view) elif self.attr: mapped_view = self.map_nonclass_attr(view) - if self.attr is not None: - mapped_view.__text__ = 'attr %s of %s' % ( - self.attr, object_description(view)) - else: - mapped_view.__text__ = object_description(view) + if inspect.isroutine(mapped_view): + # we potentially mutate an unwrapped view here if it's a function; + # we do this to avoid function call overhead of injecting another + # wrapper + if self.attr is not None: + mapped_view.__text__ = 'attr %s of %s' % ( + self.attr, object_description(view)) + else: + mapped_view.__text__ = object_description(view) return mapped_view def map_class_requestonly(self, view): |
