Mako ‘int’ object is not callable
Sunday, October 28th, 2007
If you’re trying out Mako (the templating language) and you happen to get this error:
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/CherryPy-3.0.1-py2.4.egg/cherrypy/_cprequest.py", line 551, in respond
cherrypy.response.body = self.handler()
File "/usr/lib/python2.4/site-packages/CherryPy-3.0.1-py2.4.egg/cherrypy/_cpdispatch.py", line 24, in __call__
return self.callable(*self.args, **self.kwargs)
File "./pua.py", line 82, in index
return Template('index', {'title': 'Title!'})
File "./pua.py", line 35, in Template
return(t.render(**vars))
File "/usr/lib/python2.4/site-packages/Mako-0.1.8-py2.4.egg/mako/template.py", line 114, in render
return runtime._render(self, self.callable_, args, data)
File "/usr/lib/python2.4/site-packages/Mako-0.1.8-py2.4.egg/mako/runtime.py", line 287, in _render
_render_context(template, callable_, context, *args, **_kwargs_for_callable(callable_, data))
File "/usr/lib/python2.4/site-packages/Mako-0.1.8-py2.4.egg/mako/runtime.py", line 304, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/usr/lib/python2.4/site-packages/Mako-0.1.8-py2.4.egg/mako/runtime.py", line 337, in _exec_template
callable_(context, *args, **kwargs)
File "index_html", line 20, in render_body
TypeError: 'int' object is not callable
Check if your template lookup default_filters has an decoding for utf-8:
template_lookup = mako.lookup.TemplateLookup(
directories=[path_templates],
output_encoding='utf-8',
encoding_errors='replace',
default_filters=['decode.utf-8']
)
If it does, change ‘decode.utf-8’ to ‘decode-utf8’ (remove the dash). This will fix the error. No idea where it comes from, probably the utf-8 decoding doesn’t exist. Me and Michiel now have both suffered from this problem, so there’s bound to be more.
