Am 04.05.2007 um 10:28 schrieb Maciej Wisniowski:
What code you have to copy-paste from formlib when you add your own
I think it is common to do something like:
from zope.formlib import form
The method EditFormBase.handle_edit_action contains code to set the
status message which I have to copy-paste when I want to use it
My solution would be to add an applyChanges method to
zope.formlib.form.EditFormBase which calls the applyChanges function.
Possibly a lot of existing code uses form.applyChanges as in example
above so this may be a compatibility problem.
No, my suggestion does not break any existing code because it only
adds a new method to EditFormBase which gets called from
handle_edit_action instead of the function. This new method then
calls the applyChanges function. So you are able to overwrite the new
method in a subclass to normalize before applying.
For me it would be better to change handleSubmit method
and the way action.validate is called there.
This way validate gets 'data' parameter that already has
values from widgets, these values may be simply validated and/or
normalized. There is even no need to change edit action.
A method called "validate" should only tell valid or not (and why)
but it should not change the data.
gocept gmbh & co. kg · forsterstrasse 29 · 06112 halle/saale
www.gocept.com · fon: +49 345 12298898 · fax: +49 345 12298891
Zope3-dev mailing list