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 :/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to