Commit 1e72b7a4 by Rhett Garber

Python 2.5 compatability

parent 49c34b0c
...@@ -2,6 +2,15 @@ import re ...@@ -2,6 +2,15 @@ import re
import cgi import cgi
import collections import collections
try:
import collections.Callable
def check_callable(it):
return isinstance(it, collections.Callable)
except ImportError:
def check_callable(it):
return hasattr(it, '__call__')
modifiers = {} modifiers = {}
def modifier(symbol): def modifier(symbol):
"""Decorator for associating a function with a Mustache tag modifier. """Decorator for associating a function with a Mustache tag modifier.
...@@ -81,7 +90,7 @@ class Template(object): ...@@ -81,7 +90,7 @@ class Template(object):
it = get_or_attr(context, section_name, None) it = get_or_attr(context, section_name, None)
replacer = '' replacer = ''
if it and isinstance(it, collections.Callable): if it and check_callable(it):
replacer = it(inner) replacer = it(inner)
elif it and not hasattr(it, '__iter__'): elif it and not hasattr(it, '__iter__'):
if section[2] != '^': if section[2] != '^':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment