On 5 Jun 2008, at 11:53 , Peter Bengtsson wrote:
2008/6/5 Philipp von Weitershausen <[EMAIL PROTECTED]>:
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.

This was actually Grok development. But the interface and schema part
is all zope3.
I should have posted to zope3-dev instead.

zope-dev (my mistake to suggest zope3-dev, it's been dead for a while now)

I think a proposal on zope3-dev (plus a patch) would be welcomed.

I'm not sure how to write the proposal. Can't I just make a feature
request on launchpad or something?

An email to zope-dev would be the best. Writing a proposal is easy, it can be done in a couple of paragraphs:

1. State the current situtation
2. Identify the problem that you have with the current situation
3. Suggest a solution
4. Identify potential risks

P.S.: As you may have noticed, zope.schema fields use fields themselves to define the types of their attributes/parameters. For instance, the 'title' and 'description' arguments are zope.schema.TextLines. So, in order to make those parameters accept both unicode and pure ASCII, there are two choices:

a) change zope.schema.Text and TextLine to accept both unicode and str objects, as long as the 'str' object contained just ASCII (-> validate and _validate methods)

b) introduce another schema field that has the aforementioned properties, thus leaving Text and TextLine unchanged.

I personally prefer a), but there might be good reasons to do b). Definitely something worth discussing in your proposal :).

Zope3-users mailing list

Reply via email to