Message from discussion
How do I set my form to be a unicode string?
Received: by 10.36.127.19 with SMTP id z19mr3801973nzc.1183302317228;
Sun, 01 Jul 2007 08:05:17 -0700 (PDT)
Return-Path: <em...@christoph-haas.de>
Received: from torf.workaround.org (haas.workdsl.de [212.12.44.217])
by mx.google.com with ESMTP id v28si1630882nzb.2007.07.01.08.05.15;
Sun, 01 Jul 2007 08:05:17 -0700 (PDT)
Received-SPF: neutral (google.com: 212.12.44.217 is neither permitted nor denied by best guess record for domain of em...@christoph-haas.de)
Received: from localhost (localhost [127.0.0.1])
by torf.workaround.org (Postfix) with ESMTP id A6639FFF1
for <pylons-discuss@googlegroups.com>; Sun, 1 Jul 2007 17:05:14 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at torf.workaround.org
Received: from torf.workaround.org ([127.0.0.1])
by localhost (torf.workaround.org [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id Txd2z+vuIDdK for <pylons-discuss@googlegroups.com>;
Sun, 1 Jul 2007 17:05:14 +0200 (CEST)
Received: from laptux.ov.otto.de (ottobook.workaround.org [212.12.58.138])
by torf.workaround.org (Postfix) with ESMTP id 024A1FFF0
for <pylons-discuss@googlegroups.com>; Sun, 1 Jul 2007 17:05:13 +0200 (CEST)
Received: by laptux.ov.otto.de (Postfix, from userid 1000)
id 2368B4149; Sun, 1 Jul 2007 17:05:14 +0200 (CEST)
Date: Sun, 1 Jul 2007 17:05:13 +0200
From: Christoph Haas <em...@christoph-haas.de>
To: pylons-discuss@googlegroups.com
Subject: Re: How do I set my form to be a unicode string?
Message-ID: <20070701150513.GC4666@laptux.ov.otto.de>
References: <32cabba0706300755s4c5857e1m35dcadd5ab563fec@mail.gmail.com> <20070701074607.GA4666@laptux.ov.otto.de> <32cabba0707010727j420d3bbbo4f2fefec30f1357c@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <32cabba0707010727j420d3bbbo4f2fefec30f1357c@mail.gmail.com>
X-Binford: 2000 (more power)
User-Agent: Mutt/1.5.13 (2006-08-11)
On Sun, Jul 01, 2007 at 11:27:38AM -0300, Walter Cruz wrote:
> Well, I asked before search the in the list archives!
Sorry, no. If you like to continue the topic you brought up with another
thread then please use the other thread. I didn't follow the other
thread. If you start a new thread then I recommend you put all necessary
information into it.
> What I needed:
>
> tmpl_options['mako.input_encoding'] = 'UTF-8'
> tmpl_options['mako.output_encoding'] = 'UTF-8'
> tmpl_options['mako.default_filters'] = ['decode.utf8']
> request_settings = dict(charset='utf-8', errors='replace')
> return pylons.config.Config(tmpl_options, map,
> paths,request_settings=request_settings)
You shouldn't need the mako.default_filters setting. IMHO it slows done
things unnecessarily. The request_settings parameter does the work
already.
> In environment.py
>
> I changed my formencode validator to: UnicodeString and now it's ok.
Very good.
> But I'm with a doubt:
>
> Even with this, in my templates I've to use:
>
> ${h.link_to(u"Nova citação", h.url(action="new"))}
>
> (Note the u before "Nova citação").
>
> How can I configure this to avoid to say that this is string is unicode?
You can't. A string contains 7-bit character in Python. So if you use
anything besides 7-bit ASCII you need to use unicode objects. Generally
(not only with Pylons) it's wise to always use Unicode internally and
just convert them on input/output. Trust me - it will save you time and
hassle.
Kindly
Christoph