From: Richard Eames Date: Tue, 16 Apr 2013 05:49:02 +0000 (-0600) Subject: - Allow callable classes to have contextfunction and the like X-Git-Tag: 2.7~71^2~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71fc2288795e5db02af4ec9515af4b034491b90f;p=thirdparty%2Fjinja.git - Allow callable classes to have contextfunction and the like --- diff --git a/jinja2/runtime.py b/jinja2/runtime.py index 5c399841..dd49426c 100644 --- a/jinja2/runtime.py +++ b/jinja2/runtime.py @@ -171,6 +171,17 @@ class Context(object): """ 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', + 'environmentfunction'): + if hasattr(fn, fn_type): + __obj = fn + break; + if isinstance(__obj, _context_function_types): if getattr(__obj, 'contextfunction', 0): args = (__self,) + args