From 9962c10b258472d7e07ec4d447d21fcee9d998c2 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sat, 18 May 2013 11:58:12 +0100 Subject: [PATCH] Cleanup and changelog entry for new contextfunction behavior --- CHANGES | 1 + jinja2/runtime.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 6539c5fd0..c2cd4a436 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,7 @@ Version 2.7 want to change this encoding they can override the filter. - Accessing `last` on the loop context no longer causes the iterator to be consumed into a list. +- Allow `contextfunction` and other decorators to be applied to `__call__`. Version 2.6 ----------- diff --git a/jinja2/runtime.py b/jinja2/runtime.py index dd49426ca..34259d801 100644 --- a/jinja2/runtime.py +++ b/jinja2/runtime.py @@ -171,17 +171,17 @@ def call(__self, __obj, *args, **kwargs): """ if __debug__: __traceback_hide__ = True - + # Allow callable classes to take a context if hasattr(__obj, '__call__'): fn = __obj.__call__ - for fn_type in ('contextfunction', - 'evalcontextfunction', + for fn_type in ('contextfunction', + 'evalcontextfunction', 'environmentfunction'): if hasattr(fn, fn_type): __obj = fn - break; - + break + if isinstance(__obj, _context_function_types): if getattr(__obj, 'contextfunction', 0): args = (__self,) + args