Hi.

Sorry, I missed very important thing.
I've set default encoding to utf-8.

>>> sys.getdefaultencoding()
'utf-8'

I set default encoding to 'ascii', and I saw the same error.

I think Mako does'nt use encoding settings in decoding.


2007/7/27, Walter Cruz <[EMAIL PROTECTED]>:
>
> And, with a simple wsgi app lie the on in
> http://svn.turbogears.org/projects/ToscaWidgets/branches/pre_post_hooks_removal/examples/wsgi_app.py
>
> If I put "José" in the person name, it generates the same error:
>
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> 3: ordinal not in range(128)
> []'s
> - Walter
>
> On 7/26/07, Walter Cruz <[EMAIL PROTECTED]> wrote:
> > Hi Atsushi Odagiri! A part of this was my fault, i was using
> > render_template from core pylons, and not from
> > toscawidgets.mods.pylonshf .
> >
> > But i'm not without doubts yet :(
> >
> > My data are being saved as utf-8. To insert a data in the database,
> > it's ok. But, if I edit a data that's with some accented char, the
> > error happens.
> >
> > Looks to me that the error is here :
> >
> > context.write(unicode(c.form.display(value=c.value,action='../save/' +
> > str(c.value.id))))
> >
> > I dont know, but I think that the unicode call here is the trouble. Or
> > c.form.display returns the string in a wrong encode.
> >
> > In my twForms, If I put a accented char in a label_field (like:
> > label_text = u'Matrícula') the problem happens to.
> >
> > My templates have the unicode commentary and I have this in my 
> > environment.py :
> >
> >     tmpl_options['mako.input_encoding'] = 'UTF-8'
> >     tmpl_options['mako.output_encoding'] = 'UTF-8'
> >     config['pylons.request_options']['charset'] = 'utf-8'
> >
> > []'s
> > - Walter
> >
> > On 7/26/07, Atsushi Odagiri <[EMAIL PROTECTED]> wrote:
> > >
> > > Hi Walter.
> > >
> > > Try the ways I think.
> > >
> > > Write coding settings on first line of mako template.
> > > # -*- coding:utf-8 -*-
> > >
> > > Use unicode for values with twforms.
> > >
> > > Take care.
> > >
> > > aodag
> > >
> > > 2007/7/26, Walter Cruz <[EMAIL PROTECTED]>:
> > > >
> > > > Hi all..
> > > > I and a friend have a project that we use to learn about Pylons.
> > > >
> > > > Today, I have tried to upgrade it to Pylons 0.96.
> > > >
> > > > Everything gets fine (I haven't upgraded to SAContext, but I will do 
> > > > that ASAP).
> > > >
> > > > But, we use twforms, and a problem arises:
> > > >
> > > >
> > > > The traceback:
> > > >
> > > > File 
> > > > '/home/digo/devel/python/pylon_projects/ferlons/ferlons/controllers/usuario.py',
> > > > line 32 in edit
> > > >   return render_response('/usuario-edit.html')
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Pylons-0.9.6rc1-py2.5.egg/pylons/templating.py',
> > > > line 357 in render_response
> > > >   response.content = render(*args, **kargs)
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Pylons-0.9.6rc1-py2.5.egg/pylons/templating.py',
> > > > line 338 in render
> > > >   format=format, namespace=kargs, **cache_args)
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Pylons-0.9.6rc1-py2.5.egg/pylons/templating.py',
> > > > line 225 in render
> > > >   **options)
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Mako-0.1.8-py2.5.egg/mako/ext/turbogears.py',
> > > > line 49 in render
> > > >   return template.render(**info)
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Mako-0.1.8-py2.5.egg/mako/template.py',
> > > > line 114 in render
> > > >   return runtime._render(self, self.callable_, args, data)
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Mako-0.1.8-py2.5.egg/mako/runtime.py',
> > > > line 287 in _render
> > > >   _render_context(template, callable_, context, *args,
> > > > **_kwargs_for_callable(callable_, data))
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Mako-0.1.8-py2.5.egg/mako/runtime.py',
> > > > line 304 in _render_context
> > > >   _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Mako-0.1.8-py2.5.egg/mako/runtime.py',
> > > > line 337 in _exec_template
> > > >   callable_(context, *args, **kwargs)
> > > > File 
> > > > '/home/digo/devel/python/pylon_projects/ferlons/data/templates/base.html.py',
> > > > line 28 in render_body
> > > >   context.write(filters.decode.utf8(next.body()))
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Mako-0.1.8-py2.5.egg/mako/runtime.py',
> > > > line 193 in <lambda>
> > > >   return lambda *args, **kwargs:callable_(self.context, *args, **kwargs)
> > > > File 
> > > > '/home/digo/devel/python/pylon_projects/ferlons/data/templates/usuario-edit.html.py',
> > > > line 31 in render_body
> > > >   
> > > > context.write(filters.decode.utf8(c.form.display(c.usuario,action=u'../save/'
> > > > + unicode(c.usuario.id))))
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Mako-0.1.8-py2.5.egg/mako/filters.py',
> > > > line 48 in decode
> > > >   return str(x)
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/core.py',
> > > > line 192 in __str__
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/core.py',
> > > > line 154 in render
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/output.py',
> > > > line 45 in encode
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/output.py',
> > > > line 176 in __call__
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/output.py',
> > > > line 519 in __call__
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/output.py',
> > > > line 679 in __call__
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/output.py',
> > > > line 459 in __call__
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/core.py',
> > > > line 212 in _ensure
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/template/markup.py',
> > > > line 246 in _include
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/template/markup.py',
> > > > line 291 in _match
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/template/markup.py',
> > > > line 236 in _exec
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/template/base.py',
> > > > line 432 in _eval
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/template/base.py',
> > > > line 398 in _eval
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/template/base.py',
> > > > line 442 in _flatten
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/core.py',
> > > > line 212 in _ensure
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/template/markup.py',
> > > > line 246 in _include
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/template/markup.py',
> > > > line 291 in _match
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/template/markup.py',
> > > > line 236 in _exec
> > > > File 
> > > > '/usr/lib/python2.5/site-packages/Genshi-0.4.3-py2.5.egg/genshi/template/base.py',
> > > > line 417 in _eval
> > > > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> > > > 2: ordinal not in range(128)
> > > >
> > > > Acording to that entries on tracs
> > > > (http://www.makotemplates.org/trac/ticket/35 and
> > > > trac.turbogears.org/ticket/1329) the problem is fixed. I've put:
> > > >
> > > >     tmpl_options['mako.input_encoding'] = 'utf-8'
> > > >     tmpl_options['mako.output_encoding'] = 'utf-8'
> > > >
> > > > in my environment.py
> > > >
> > > > Everything works, except by this twForm.
> > > >
> > > > Can someone help me?
> > > >
> > > > []'s
> > > > - Walter
> > > >
> > > > >
> > > >
> > >
> > >
> > > --
> > > /*
> > > Atsushi Odagiri
> > > http://d.hatena.ne.jp/aodag/
> > > http://aodag.tumblr.com
> > > mailto:[EMAIL PROTECTED]
> > > */
> > >
> > > > >
> > >
> >
>
> >
>


-- 
/*
Atsushi Odagiri
http://d.hatena.ne.jp/aodag/
http://aodag.tumblr.com
mailto:[EMAIL PROTECTED]
*/

--~--~---------~--~----~------------~-------~--~----~
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