Actually, yes, this flag has no effect when i was trying. But, we have resolved it. We save the .myt file into encoding utf-8, and add a line to the top of the myt file:
# encoding: utf-8 The Myghty will add the line into the translated .myt.py file like this: # File: templates|base.myt CompilerID: Myghty.Lexer|Myghty.Compiler| (5, {'disable_unicode': False}) Timestamp: Wed May 16 16:12:52 2007 # -*- encoding: utf-8 -*- so, everything is ok. On Apr 5, 11:07 pm, Chris Shenton <[EMAIL PROTECTED]> 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 > > I've read up on this and found suggestions in > > http://www.myghty.org/docs/params.myt#parameters_output_encoding > > to set encoding in config/environment.py, which I've done: > > myghty = {} > myghty['log_errors'] = True > myghty['escapes'] = dict(l=webhelpers.auto_link, > s=webhelpers.simple_format) > > myghty['output_encoding'] = 'utf-8' > myghty['encoding_errors'] = 'htmlentityreplace' > > return pylons.config.Config(myghty, map, paths) > > but this didn't help. The error continued to complain about "ascii" > codec so it looks like this setting above isn't getting seen by > myghty. It also suggested setting this in the mod_python section of > my Apache config, which I also tried: > > <Location /er> > SetHandler mod_python > Pythonhandler mod_python.wsgi > PythonPath "['/usr/local/clientjob] + sys.path" > PythonOption wsgi.application startup-bluecoat::app > PythonOption SCRIPT_NAME /er > # 2007-04-05 setting in config/environment.py isnt' working? > PythonOption MyghtyOutputEncoding "utf-8" > PythonOption MyghtyEncodingErrors > "htmlentityreplace" > </Location> > > But this also had no effect, same complaint about "ascii". > > http://pylonshq.com/docs/internationalization.htmlsaid I could do the > following, again in config/environment.py: > > tmpl_options['myghty.output_encoding'] = 'UTF-8' > > but that file didn't know about the "tmpl_options" dict. > > I've seen similar suggestion to the above in a #pylons IRC transcript > but none of these are working for me. Why is it still using an > "ascii" codec when I've set it in two different places? > > I've tried removing the template cache .py and .pyc files but that had > no effect. > > I was finally able to get things to work by creating > .../site-packages/sitecustomize.py: > > import sys > sys.setdefaultencoding('utf-8') > > and saw that one of my clients names was an O-umlaut. (Should I now > expect surprises from other things, like the fact that I'm not using > unicode strings in my python?) > > I'd really like to do this in Pylons or Myghty instead than site-wide > and don't understand why the documented mechanisms don't work for me. > > Any suggestions? Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---