diff options
| -rw-r--r-- | CHANGES.txt | 16 | ||||
| -rw-r--r-- | pyramid/config/views.py | 19 | ||||
| -rw-r--r-- | pyramid/tests/test_view.py | 2 | ||||
| -rw-r--r-- | pyramid/util.py | 5 | ||||
| -rw-r--r-- | pyramid/view.py | 18 |
5 files changed, 40 insertions, 20 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 841d2ebec..9d3a017ab 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,19 @@ +next release +============ + +Backwards Incompatibilities +--------------------------- + +- Modified the ``_depth`` argument to ``pyramid.view.view_config`` to accept + a value relative to the invocation of ``view_config`` itself. Thus, when it + was previously expecting a value of ``1`` or greater, to reflect that + the caller of ``view_config`` is 1 stack frame away from ``venusian.attach``, + this implementation detail is now hidden. + +- Modified the ``_backframes`` argument to ``pyramid.util.action_method`` in a + similar way to the changes described to ``_depth`` above. This argument + remains undocumented, but might be used in the wild by some insane person. + 1.4b1 (2012-11-21) ================== diff --git a/pyramid/config/views.py b/pyramid/config/views.py index d1b69566b..e4217f2f3 100644 --- a/pyramid/config/views.py +++ b/pyramid/config/views.py @@ -37,7 +37,6 @@ from pyramid import renderers from pyramid.compat import ( string_types, urlparse, - im_func, url_quote, WIN, is_bound_method, @@ -1025,14 +1024,16 @@ class ViewsConfiguratorMixin(object): custom_predicates - This value should be a sequence of references to custom - predicate callables. Use custom predicates when no set of - predefined predicates do what you need. Custom predicates - can be combined with predefined predicates as necessary. - Each custom predicate callable should accept two arguments: - ``context`` and ``request`` and should return either - ``True`` or ``False`` after doing arbitrary evaluation of - the context and/or the request. + This value should be a sequence of references to custom predicate + callables. Use custom predicates when no set of predefined + predicates do what you need. Custom predicates can be combined with + predefined predicates as necessary. Each custom predicate callable + should accept two arguments: ``context`` and ``request`` and should + return either ``True`` or ``False`` after doing arbitrary evaluation + of the context and/or the request. The ``predicates`` argument to + this method and the ability to register third-party view predicates + via :meth:`pyramid.config.Configurator.add_view_predicate` obsoletes + this argument, but it is kept around for backwards compatibility. predicates diff --git a/pyramid/tests/test_view.py b/pyramid/tests/test_view.py index a78b0cbab..a0d476662 100644 --- a/pyramid/tests/test_view.py +++ b/pyramid/tests/test_view.py @@ -541,7 +541,7 @@ class TestViewConfigDecorator(unittest.TestCase): self.assertEqual(config.pkg, pyramid.tests) def test_call_withdepth(self): - decorator = self._makeOne(_depth=2) + decorator = self._makeOne(_depth=1) venusian = DummyVenusian() decorator.venusian = venusian def foo(): pass diff --git a/pyramid/util.py b/pyramid/util.py index ca7f5951c..a8f750a46 100644 --- a/pyramid/util.py +++ b/pyramid/util.py @@ -471,8 +471,9 @@ def viewdefaults(wrapped): view = self.maybe_dotted(view) if inspect.isclass(view): defaults = getattr(view, '__view_defaults__', {}).copy() + if not '_backframes' in kw: + kw['_backframes'] = 1 # for action_method defaults.update(kw) - defaults['_backframes'] = 3 # for action_method return wrapped(self, *arg, **defaults) return functools.wraps(wrapped)(wrapper) @@ -498,7 +499,7 @@ def action_method(wrapped): self._ainfo = [] info = kw.pop('_info', None) # backframes for outer decorators to actionmethods - backframes = kw.pop('_backframes', 2) + backframes = kw.pop('_backframes', 0) + 2 if is_nonstr_iter(info) and len(info) == 4: # _info permitted as extract_stack tuple info = ActionInfo(*info) diff --git a/pyramid/view.py b/pyramid/view.py index 1a66c9e9c..e1e03bd93 100644 --- a/pyramid/view.py +++ b/pyramid/view.py @@ -178,14 +178,16 @@ class view_config(object): out, its default will be the equivalent ``add_view`` default. An additional keyword argument named ``_depth`` is provided for people who - wish to reuse this class from another decorator. It will be passed in to - the :term:`venusian` ``attach`` function as the depth of the callstack when - Venusian checks if the decorator is being used in a class or module - context. It's not often used, but it can be useful in this circumstance. - See the ``attach`` function in Venusian for more information. + wish to reuse this class from another decorator. The default value is + ``0`` and should be specified relative to the ``view_config`` invocation. + It will be passed in to the :term:`venusian` ``attach`` function as the + depth of the callstack when Venusian checks if the decorator is being used + in a class or module context. It's not often used, but it can be useful + in this circumstance. See the ``attach`` function in Venusian for more + information. See :ref:`mapping_views_using_a_decorator_section` for details about - using :class:`view_config`. + using :class:`pyramid.view.view_config`. """ venusian = venusian # for testing injection @@ -197,14 +199,14 @@ class view_config(object): def __call__(self, wrapped): settings = self.__dict__.copy() - depth = settings.pop('_depth', 1) + depth = settings.pop('_depth', 0) def callback(context, name, ob): config = context.config.with_package(info.module) config.add_view(view=ob, **settings) info = self.venusian.attach(wrapped, callback, category='pyramid', - depth=depth) + depth=depth + 1) if info.scope == 'class': # if the decorator was attached to a method in a class, or |
