summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-12-29 18:22:37 -0500
committerChris McDonough <chrism@plope.com>2010-12-29 18:22:37 -0500
commit2953baaebadfb267e1fa98d35605b88ff2274052 (patch)
tree579a72f953521f23fd806830918c6771f1727bac
parent73741f6f97dce4d3f8ee340a708823db75c7aef6 (diff)
downloadpyramid-2953baaebadfb267e1fa98d35605b88ff2274052.tar.gz
pyramid-2953baaebadfb267e1fa98d35605b88ff2274052.tar.bz2
pyramid-2953baaebadfb267e1fa98d35605b88ff2274052.zip
make sure view returned from view mapper preserves all attrs
-rw-r--r--pyramid/config.py6
-rw-r--r--pyramid/tests/test_config.py9
2 files changed, 11 insertions, 4 deletions
diff --git a/pyramid/config.py b/pyramid/config.py
index b8b47f686..077db28ab 100644
--- a/pyramid/config.py
+++ b/pyramid/config.py
@@ -2910,7 +2910,6 @@ class DefaultViewMapper(object):
return False
- @wraps_view
def __call__(self, view):
attr = self.kw.get('attr')
decorator = self.kw.get('decorator')
@@ -2931,6 +2930,7 @@ class DefaultViewMapper(object):
view = preserve_view_attrs(view, decorated_view)
return view
+ @wraps_view
def map_requestonly_class(self, view):
# its a class that has an __init__ which only accepts request
attr = self.kw.get('attr')
@@ -2956,6 +2956,7 @@ class DefaultViewMapper(object):
return response
return _class_requestonly_view
+ @wraps_view
def map_class(self, view):
# its a class that has an __init__ which accepts both context and
# request
@@ -2981,6 +2982,7 @@ class DefaultViewMapper(object):
return response
return _class_view
+ @wraps_view
def map_requestonly_func(self, view):
# its a function or instance that has a __call__ accepts only a
# single request argument
@@ -3007,6 +3009,7 @@ class DefaultViewMapper(object):
return response
return _requestonly_view
+ @wraps_view
def map_attr(self, view):
# its a function that has a __call__ which accepts both context and
# request, but still has an attr
@@ -3029,6 +3032,7 @@ class DefaultViewMapper(object):
return response
return _attr_view
+ @wraps_view
def map_rendered(self, view):
# it's a function that has a __call__ that accepts both context and
# request, but requires rendering
diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py
index 80e675623..d237592d5 100644
--- a/pyramid/tests/test_config.py
+++ b/pyramid/tests/test_config.py
@@ -741,14 +741,17 @@ class ConfiguratorTests(unittest.TestCase):
def test_add_view_with_decorator(self):
def view(request):
+ """ ABC """
return 'OK'
def view_wrapper(fn):
- fn.__assert_wrapped__ = True
- return fn
+ def inner(context, request):
+ return fn(context, request)
+ return inner
config = self._makeOne(autocommit=True)
config.add_view(view=view, decorator=view_wrapper)
wrapper = self._getViewCallable(config)
- self.assertTrue(getattr(wrapper, '__assert_wrapped__', False))
+ self.failIf(wrapper is view)
+ self.assertEqual(wrapper.__doc__, view.__doc__)
result = wrapper(None, None)
self.assertEqual(result, 'OK')