Thanks very much guys.  Next app I plan on using SQLAlchemy for my first 
time.

Marius, would it be better to decode to utf8 during __setattr__() vs 
__getattribute__()?

It seems to me that they'd give the same results.  Whichever is accesses 
less would be a more efficient place to put the decode (which is probably 
application dependent).


-Mike





On Thursday, April 19, 2012 11:11:17 AM UTC-4, Marius Gedminas wrote:
>
> On Tue, Apr 17, 2012 at 09:13:33AM -0700, Michael Gimbel wrote:
> > I'm encountering MakoRenderingException and UnicodeDecodeError
> > exceptions throughout my application when trying to render utf8 data
> > which was originally user input.
> > 
> > There don't seem to be Pyramid configuration options for Mako's
> > output_encoding='utf-8', encoding_errors='replace'.
> > 
> > Python/Mako magic doesn't seem to be doing it either, ## -*- coding:
> > utf-8 -*-
> > 
> > I've tried using a mako filter, which helped: mako.default_filters =
> > decode.utf8 (in .ini file)
> > But I still have problems anywhere I'm using filters or functions in
> > my templates: ${var_with_utf8_chars | custom_filter}
> > This seems to fix it but I don't want to have to do this throughout
> > the entire application: ${var_with_utf8_chars.decode('utf8') }
> > custom_filter}
> > 
> > I was thinking if the above is the only way, the best place to do it
> > would be at the model level when the utf8 data is loaded out of the
> > database.  But I was hoping for a better, more magical solution.
>
> Decoding UTF-8 data into Unicode objects at the model level _is_ the
> better solution.  E.g. SQLAlchemy can do that seamlessly.
>
> Marius Gedminas
> -- 
> Never trust a smiling Gates.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/pylons-discuss/-/GBL2m0m9SG8J.
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