Re: [Zope3-dev] Formlib error handling

2006-05-18 Thread Gary Poster


On May 17, 2006, at 9:27 PM, [EMAIL PROTECTED] [EMAIL PROTECTED]  
wrote:

From: Gary Poster [mailto:[EMAIL PROTECTED]
On Apr 22, 2006, at 11:31 AM, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:

The formlib.EditForm dosen't catch all errors form widgets.

...

I solve the problem and added some bugfix, see the different
commit messages below.


Awesome.  Some comments below.

...

Log message for revision 68157:
  - Improve error handling in formlib:
Fix invariant error handling in formlib. The exception Invalid  
raised
in interface invariants where end in a component lookup error  
because

this exception didn't get converted to a usefull error message.
Now the error_views method in formlib can handle strings and i18n
Message based Invalid exceptions.


With your change, if the error is (or extends!) Invalid, it is  
hardcoded to assume the first argument is a string, message, or  
something with a reasonably __str__, translate if it is a message,  
and wrap the result with a span.  I'd much prefer it if that code  
were ripped out of error_views and made, simply, into a view for  
(Invalid, IBrowserRequest), perhaps even registered by the formlib  
zcml.  Do you see any issue with that?


Also, I don't love the 'widget_title' stuff in error_views: that  
seems to me to be the responsibility of the error view.Is that  
new?  What's the rationale?



Log message for revision 67278:
  Fix error handling, please double check this!

  The formlib.form.EditForm doesn't handle ValidationError in the
  method error_views.
  I converted ValidationError to WidgetInputError in the method
  getWidgetsData which is responsible to catch errors raised by
  the widget getInputValue method.


This is the place in the code that knows the widget name and label,  
so it's not unreasonable.


Thanks

Gary
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



RE: [Zope3-dev] Formlib error handling

2006-05-18 Thread dev
Hi Gary

[...]
 With your change, if the error is (or extends!) Invalid, it 
 is hardcoded to assume the first argument is a string, 
 message, or something with a reasonably __str__, translate if 
 it is a message, and wrap the result with a span.  I'd much 
 prefer it if that code were ripped out of error_views and 
 made, simply, into a view for (Invalid, IBrowserRequest), 
 perhaps even registered by the formlib zcml.  Do you see any 
 issue with that?

No, that's a good idea. btw, I can also live without the
additional span tag arround the message string. Do you
have time to change this?

 Also, I don't love the 'widget_title' stuff in error_views: that  
 seems to me to be the responsibility of the error view.Is that  
 new?  What's the rationale?

No, this was a existing part. I agree, we sould move this part to 
the error view, if possible.

  Log message for revision 67278:
Fix error handling, please double check this!
 
The formlib.form.EditForm doesn't handle ValidationError in the
method error_views.
I converted ValidationError to WidgetInputError in the method
getWidgetsData which is responsible to catch errors raised by
the widget getInputValue method.
 
 This is the place in the code that knows the widget name and 
 label, so it's not unreasonable.

What do you mean by this? Is it correct how I converted 
ValidationError to useable widget input errors?

Regards
Roger Ineichen

 Thanks
 
 Gary
 

___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Formlib error handling

2006-05-18 Thread Gary Poster


On May 18, 2006, at 4:12 PM, [EMAIL PROTECTED] wrote:


Hi Gary

[...]

With your change, if the error is (or extends!) Invalid, it
is hardcoded to assume the first argument is a string,
message, or something with a reasonably __str__, translate if
it is a message, and wrap the result with a span.  I'd much
prefer it if that code were ripped out of error_views and
made, simply, into a view for (Invalid, IBrowserRequest),
perhaps even registered by the formlib zcml.  Do you see any
issue with that?


No, that's a good idea. btw, I can also live without the
additional span tag arround the message string. Do you
have time to change this?


Heh, not right now.  Maybe next week.


Also, I don't love the 'widget_title' stuff in error_views: that
seems to me to be the responsibility of the error view.Is that
new?  What's the rationale?


No, this was a existing part. I agree, we sould move this part to
the error view, if possible.


Hm.  I wonder who did this then.  Maybe I'll poke around. :-)


Log message for revision 67278:
  Fix error handling, please double check this!

  The formlib.form.EditForm doesn't handle ValidationError in the
  method error_views.
  I converted ValidationError to WidgetInputError in the method
  getWidgetsData which is responsible to catch errors raised by
  the widget getInputValue method.


This is the place in the code that knows the widget name and
label, so it's not unreasonable.


What do you mean by this? Is it correct how I converted
ValidationError to useable widget input errors?


Sorry for being unclear.

What you did makes sense.  I have intuitive reservations that I am  
discounting because I cannot rationalize them.  Therefore, +1 to what  
you did.


Gary
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Formlib error handling

2006-05-17 Thread Gary Poster


On Apr 22, 2006, at 11:31 AM, [EMAIL PROTECTED] [EMAIL PROTECTED]  
wrote:



The formlib.EditForm dosen't catch all errors form widgets.

...

Hey Roger.  Your email has been sitting open on my computer for  
weeks, reminding me to reply, and I want to get rid of it. :-)  Did  
you put a collector issue in for this, or was it resolved in some  
other way?


Thanks

Gary
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



RE: [Zope3-dev] Formlib error handling

2006-05-17 Thread dev
Hi Gary,

 -Original Message-
 From: Gary Poster [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, May 17, 2006 7:36 PM
 To: [EMAIL PROTECTED]
 Cc: zope3-dev@zope.org
 Subject: Re: [Zope3-dev] Formlib error handling
 
 
 On Apr 22, 2006, at 11:31 AM, [EMAIL PROTECTED] [EMAIL PROTECTED]
 wrote:
 
  The formlib.EditForm dosen't catch all errors form widgets.
 ...
 
 Hey Roger.  Your email has been sitting open on my computer 
 for weeks, reminding me to reply, and I want to get rid of 
 it. :-)  Did you put a collector issue in for this, or was it 
 resolved in some other way?

I solve the problem and added some bugfix, see the different 
commit messages below.

I think the error handling is pretty Ok in the formlib now.
Feel free to ask if somthing is unclear. I'm pretty sure
that we very extensivly used the formlib in our project.
Most improvments depend on useing the formlib with subforms
where we setup in the update method.
Some implementation use also the zc.table implementation.

What I like to implement, is a generic sub form setup
method which should make it easier to setup sub-forms.

Log message for revision 68157:
  - Improve error handling in formlib:
Fix invariant error handling in formlib. The exception Invalid raised 
in interface invariants where end in a component lookup error because
this exception didn't get converted to a usefull error message.
Now the error_views method in formlib can handle strings and i18n 
Message based Invalid exceptions.
  - Added test for Invalid exceptions handling
  - Added also a small fix which makes sure that existing errors
from master/subforms don't get overriden by calling update in 
FormBase.
  - Added note in Changes.txt

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/formlib/form.py
  U   Zope3/trunk/src/zope/formlib/tests.py


Log message for revision 67282:
  Fix error handling
  
  Widget have to raise WidgetInputError and not ValidationError
  directly. Improve sequence input widget base class methods
  getInputValue. This will ensure that sequence widgets will
  set the raised error to the _error attribute before the error
  get raised.

Changed:
  U   Zope3/trunk/src/zope/app/form/browser/sequencewidget.py
  U   Zope3/trunk/src/zope/app/form/browser/tests/test_sequencewidget.py


Log message for revision 67279:
  And added missing import

Changed:
  U   Zope3/trunk/src/zope/formlib/form.py


Log message for revision 67278:
  Fix error handling, please double check this!
  
  The formlib.form.EditForm doesn't handle ValidationError in the
  method error_views. 
  I converted ValidationError to WidgetInputError in the method
  getWidgetsData which is responsible to catch errors raised by
  the widget getInputValue method.

Changed:
  U   Zope3/trunk/src/zope/formlib/form.py

Regards
Roger Ineichen
_
END OF MESSAGE

 Thanks
 
 Gary
 

___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com