On Apr 5, 2007, at 8:07 AM, Chris Shenton wrote:
>
> Using Pylons-0l9.4.1 and Myghty-1.1. I can't seem to set encoding to
> utf-8 for Myghty or mod_python so that Pylons gets it.
>
> My app was working well but just started bombing, likely because one
> of my techs entered a name into a form which had non-ascii chars, and
> then the rendering in the display failed. When I run with debug
> enabled, I get a bit more info:
>
> Error: Error(UnicodeDecodeError): 'ascii' codec can't decode
> byte 0xc3
> in position 15: ordinal not in range(128)
> File: /usr/local/clientproj/er/templates/vendor_show.myt line 11
> Context: 8:
> <tr><th>Client Name</th><th>Updated</th><th>Created</th></tr>
> 9: % for client in c.clients:
> 10: <tr>
> 11: <td><a href="<%h.url_for('client_show',
> client_id=client.client_id)%>"><%client.name%></a></td>
> 12: <td><%client.ts_updated%></td>
> 13: <td><%client.ts_created%></td>
> 14: </tr>
>
>
> Error - myghty.exception.Error: Error(UnicodeDecodeError?):
> 'ascii' codec can't decode byte 0xc3 in position 15: ordinal not
> in range(128) at
> /usr/local/lib/python2.4/site-packages/Myghty-1.1-py2.4.egg/
> myghty/requestbuffer.py
> line 367
Setting your default system encoding to utf-8 will work -- but it's
incredibly inconvenient, as you've noticed, especially when deploying
your app to new environments.
The output encoding setting is how the final, rendered string Myghty
returns will be encoded to. The UnicodeDecodeError you're seeing is
due to the incoming data passed to Myghty, it occurs when Myghty
converts everything to unicode internally. It defaults to the
system's default encoding (ascii) when converting inputted strings to
unicode.
The correct way to solve this problem is to pass Myghty unicode
objects. The other option is to disable unicode support in Myghty,
via the global 'disable_unicode' option, or on a template by template
basis by passing disable_unicode=True to Pylons' render function.
--
Philip Jenvey
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---