On Mar 31, 2009, at 9:17 AM, Max Ischenko wrote:

I have migrated my codebase to 0.9.7 and when I'm trying to use render_mako instead of render() I get a strange error:

File '/Users/amaslov/Projects/dou-pylons/doupy/doupy/controllers/ root.py', line 239 in staticpage
 return render('/pages/%s.html' % name)
File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site- packages/Pylons-0.9.7-py2.5.egg/pylons/templating.py', line 274 in render_mako
 cache_type=cache_type, cache_expire=cache_expire)
File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site- packages/Pylons-0.9.7-py2.5.egg/pylons/templating.py', line 249 in cached_template
 return render_func()
File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site- packages/Pylons-0.9.7-py2.5.egg/pylons/templating.py', line 271 in render_template
 return literal(template.render_unicode(**globs))
File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site- packages/Mako-0.2.4-py2.5.egg/mako/template.py', line 138 in render_unicode return runtime._render(self, self.callable_, args, data, as_unicode=True) File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site- packages/Mako-0.2.4-py2.5.egg/mako/runtime.py', line 348 in _render
 return context._pop_buffer().getvalue()
File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site- packages/Mako-0.2.4-py2.5.egg/mako/util.py', line 74 in getvalue
 return self.delim.join(self.data)
TypeError: sequence item 68: expected string or Unicode, NoneType found

Generally this is caused when you have a component (mako def) that is echoing some value out. I think its because the default escaper that is now used with Mako will *not* turn a None into a '' during escaping. Check to see that you don't have anything in a ${} somewhere that might evaluate to a None as that will cause it. I'm looking at fixing the default escaper so that None's become a '' instead and don't cause this Mako bug, though its possible some people will want to know when something in a ${} that *should* return something is instead returning None.

Cheers,
Ben

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to