]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
- Allow callable classes to have contextfunction and the like 200/head
authorRichard Eames <naddiseo@gmail.com>
Tue, 16 Apr 2013 05:49:02 +0000 (23:49 -0600)
committerRichard Eames <naddiseo@gmail.com>
Tue, 16 Apr 2013 05:49:02 +0000 (23:49 -0600)
jinja2/runtime.py

index 5c39984170509b6ef56aa283874b845dac0cabbe..dd49426caab4b58561a644f6e300cd7b346ae81a 100644 (file)
@@ -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