tw.dynforms can't handle unicode labels for widgets

4 views
Skip to first unread message

Aaron Digulla

unread,
Nov 17, 2009, 11:48:39 AM11/17/09
to ToscaWidgets-discuss
Not sure whether this has been fixed or not:

tw.dynforms can't handle unicode labels for widgets. The source code
is sprinkled with calls to str() (instead of unicode()).

For an example, see tw.dynforms-0.9.1-py2.6.egg/tw/dynforms/widgets.py

My fix was to replace all calls to str() with unicode().

Diez B. Roggisch

unread,
Nov 25, 2009, 5:22:36 AM11/25/09
to toscawidge...@googlegroups.com, Aaron Digulla
I'm a bit scared of simply replacing all the str-calls with unicode. Do you
have example-code & maybe tests that support that this works?

Diez

Aaron Digulla

unread,
Nov 28, 2009, 6:48:24 AM11/28/09
to ToscaWidgets-discuss
On 25 Nov., 11:22, "Diez B. Roggisch" <de...@web.de> wrote:

> > My fix was to replace all calls to str() with unicode().
> I'm a bit scared of simply replacing all the str-calls with unicode. Do you
> have example-code & maybe tests that support that this works?

Just create a label with this text: "Über" (About, u'\u00dcber') and
then try to run this through tw. I don't have access to the tw tests
and I needed a quick solution. I'm not saying that my solution is safe
but it did work. In a web framework, str() is really dangerous since
you're always handling unicode data. I was really surprised that tw
can't handle this simple case.

Aaron

Paul Johnston

unread,
Nov 28, 2009, 9:26:30 AM11/28/09
to toscawidge...@googlegroups.com
Hi,

> Just create a label with this text: "Über" (About, u'\u00dcber') and
> then try to run this through tw. I don't have access to the tw tests
> and I needed a quick solution. I'm not saying that my solution is safe
> but it did work. In a web framework, str() is really dangerous since
> you're always handling unicode data. I was really surprised that tw
> can't handle this simple case.

I'm inclined to agree with you. I've been careful to test that unicode
works in user input. But unicode data in values derived from code is
not so widely tested, hence the problems you've mentioned.

If after changing all str to unicode, all the unit tests pass, and the
dyndemo app still works, I reckon we're good to commit them.

Paul
Reply all
Reply to author
Forward
0 new messages