[Zope3-Users] Re: Annoying thing about schema
Philipp von Weitershausen
philipp at weitershausen.de
Thu Jun 5 05:16:00 EDT 2008
Peter Bengtsson wrote:
> Suppose you've written this:
> class ISomething(zope.interface.Interface):
> foo = zope.schema.TextLine(title="Foo")
> then you get the error below.
> First of all, why can't it just help me and just convert the str to a
> unicode. All it'd need to do is just::
> title = unicode(title)
> Django does this.
> If someone does something bad like `TextLine(title="Ölmage")` that
> developer should rightly get a UnicodeDecodeError.
> Secondly, if there is an actual reason for this extreme analism, why
> can't the error be wrapped into something more user friendly?
Very good points. I think UnicodeDecodeErrors have a bad reputation,
though (mostly because of Python's stupid implicit conversion). I think
Grok's policy is very sane in this regard: wherever human-readable text
has to be entered, either a unicode object or a string just containing
ASCII characters are acceptable. A very explicit error message stating
that exact policy should be raised. Look at Grok's error messages, we've
tried hard making them understandable.
I think a proposal on zope3-dev (plus a patch) would be welcomed.
More information about the Zope3-users