Unicode and ISO-8859-2 - callback to convert...

15 views
Skip to first unread message

durumdara

unread,
May 22, 2009, 12:16:28 PM5/22/09
to Mako Templates for Python
Hi!

I port some Cheetah site to Mako.
C is uses ISO-8859-2 templates, and my datas - they are also
ISO-8859-2 encoded...

Now I use in my all view:

$(c.tounicode(param) |h}
$(c.tounicode(MailRecord['Main']) |h}
etc.

I wanna search for a solution where I can handle all of my inputs in
mako internally, and convert it to needed format...

For example:
def MyCallBack(Param):
return tounicode(Param)

RegisterCallBack(MyCallBack)

Do you know about same method to avoid this problem?

We have áíé, and other chars that are not handled by utf8, and if I
forget to write this input conversion, possible the site will
unavailable for users with a simple hungarian user input... :-(

Thanks for your help:
dd

Michael Bayer

unread,
May 22, 2009, 12:23:16 PM5/22/09
to mako-d...@googlegroups.com
durumdara wrote:
>
> Hi!
>
> I port some Cheetah site to Mako.
> C is uses ISO-8859-2 templates, and my datas - they are also
> ISO-8859-2 encoded...
>
> Now I use in my all view:
>
> $(c.tounicode(param) |h}
> $(c.tounicode(MailRecord['Main']) |h}
> etc.
>
> I wanna search for a solution where I can handle all of my inputs in
> mako internally, and convert it to needed format...
>
> For example:
> def MyCallBack(Param):
> return tounicode(Param)
>
> RegisterCallBack(MyCallBack)
>
> Do you know about same method to avoid this problem?
>
> We have ليé, and other chars that are not handled by utf8, and if I

> forget to write this input conversion, possible the site will
> unavailable for users with a simple hungarian user input... :-(

look into adding a default filter:

http://www.makotemplates.org/docs/filtering.html#filtering_expression_defaultfilters

Reply all
Reply to author
Forward
0 new messages