11 messages in com.googlegroups.pylons-discussRe: UTF-8 ... help| From | Sent On | Attachments |
|---|---|---|
| purepear | 11 Jan 2007 07:01 | |
| Damjan | 11 Jan 2007 16:42 | |
| Ian Bicking | 11 Jan 2007 16:44 | |
| Alexandre CONRAD | 12 Jan 2007 01:46 | |
| purepear | 12 Jan 2007 01:46 | |
| Matt Feifarek | 12 Jan 2007 08:26 | |
| James Gardner | 13 Jan 2007 18:10 | |
| James Gardner | 13 Jan 2007 18:12 | |
| Damjan | 14 Jan 2007 08:55 | |
| Matt Feifarek | 22 Jan 2007 20:37 | |
| MySZ | 25 Jan 2007 08:46 |
| Subject: | Re: UTF-8 ... help![]() |
|---|---|
| From: | MySZ (urze...@public.gmane.org) |
| Date: | 01/25/2007 08:46:41 AM |
| List: | com.googlegroups.pylons-discuss |
Hello,
I have similar problem. I'm using Mako templates with sqlalchemy. In templates I have line: # coding: utf-8 OK, I can put UTF-8 chars into templates. But I can't do:
${h.options_for_select( ( (u'brudnopis', u'draft'), (u'opublikowany', u'published'), (u'usunięty', u'hidden') ), c.frm_status)}
or:
<li class="${h.cond(h.current_page('/admin/news/list'), 'selected', '')}">${h.link_to_unless_current(u'Zarządzaj', h.url(controller='admin_news', action='list'))}</a></li>
or neither:
${asdą}
because it raise an exception: <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\u0119' in position 110: ordinal not in range(128)
self <compiler.transformer.Transformer instance at 0x423bde2c> text u"h.options_for_select(\n\t\t\t\t(\n\t\t\t\t\t(u'brudnopis', u'draft'),\n\t\t\t\t\t(u'opublikowany', u'published'),\n\t\t\t\t\t(u'usuni\u0119ty', u'hidden')\n\t\t\t\t), c.frm_status)"
or similar.
Of course, files are encoded in UTF-8, every file created by me have line: # -*- coding: utf-8 -*- or similar, I use only unicode objects, etc etc.
MySZ
PS. How can I do persuade sqlalchemy in Pylons to use Unicode objects? For now I hack [...]/Pylons[...]/pylons/database.py, line 42: engine = sqlalchemy.create_engine(uri, echo=echo, convert_unicode=True, encoding='utf-8')
Is any simpler method? Without this sqlalchemy doesn't work with strings with non-ascii chars :/




