From 71fc2288795e5db02af4ec9515af4b034491b90f Mon Sep 17 00:00:00 2001 From: Richard Eames Date: Mon, 15 Apr 2013 23:49:02 -0600 Subject: [PATCH] - Allow callable classes to have contextfunction and the like --- jinja2/runtime.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 -- 2.47.2