Пишу в шаблонах по-русски. Все ок
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal">
<head>
<title>Русский в шаблоне, все ОК!</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<table>
<tr tal:repeat="item items">
<td tal:content="item.id">1</td>
<td tal:content="item.name">Widget</td>
</tr>
</table>
</body>
</html>
пытаюсь передать объекты с русскими именами
@view_config(route_name='packing', renderer='templates/packing.pt')
def packing(request):
a = Item()
a.id = 0
a.name = "Тип 1"
b = Item()
b.id = 1
b.name = "Тип 2"
items = [a, b]
return {'items':items}
Traceback (most recent call last):
File "/home/counter/counter/env/lib/python2.6/site-packages/waitress-0.7-py2.6.egg/waitress/channel.py", line 276, in service
task.service()
File "/home/counter/counter/env/lib/python2.6/site-packages/waitress-0.7-py2.6.egg/waitress/task.py", line 171, in service
self.execute()
File "/home/counter/counter/env/lib/python2.6/site-packages/waitress-0.7-py2.6.egg/waitress/task.py", line 374, in execute
app_iter = self.channel.server.application(env, start_response)
File "/home/counter/counter/env/lib/python2.6/site-packages/pyramid/router.py", line 187, in __call__
response = self.handle_request(request)
File "/home/counter/counter/env/lib/python2.6/site-packages/pyramid/tweens.py", line 20, in excview_tween
response = handler(request)
File "/home/counter/counter/env/lib/python2.6/site-packages/pyramid_tm-0.3-py2.6.egg/pyramid_tm/__init__.py", line 61, in tm_tween
response = handler(request)
File "/home/counter/counter/env/lib/python2.6/site-packages/pyramid/router.py", line 164, in handle_request
response = view_callable(context, request)
File "/home/counter/counter/env/lib/python2.6/site-packages/pyramid/config/views.py", line 335, in rendered_view
context)
File "/home/counter/counter/env/lib/python2.6/site-packages/pyramid/renderers.py", line 395, in render_view
return self.render_to_response(response, system, request=request)
File "/home/counter/counter/env/lib/python2.6/site-packages/pyramid/renderers.py", line 424, in render_to_response
result = self.render(value, system_values, request=request)
File "/home/counter/counter/env/lib/python2.6/site-packages/pyramid/renderers.py", line 420, in render
result = renderer(value, system_values)
File "/home/counter/counter/env/lib/python2.6/site-packages/pyramid/chameleon_zpt.py", line 51, in __call__
result = self.template(**system)
File "/home/counter/counter/env/lib/python2.6/site-packages/chameleon/template.py", line 128, in __call__
return self.render(**kwargs)
File "/home/counter/counter/env/lib/python2.6/site-packages/chameleon/zpt/template.py", line 258, in render
return super(PageTemplate, self).render(**vars)
File "/home/counter/counter/env/lib/python2.6/site-packages/chameleon/template.py", line 175, in render
self._render(stream, econtext, rcontext)
File "/tmp/tmpIXQPHS/packing_4463c43b192d857af40f81911676f6bf427b40e3.py", line 227, in render
__content = decode(__content)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not
in range(128)
в __init__.py и views.py coding utf-8