>
> 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.
OK, I understand now.

>
> -1
> A method called "validate" should only tell valid or not (and why) but
> it should not change the data.
Currently when defining action you can use 'validator', which is in fact
called by 'validate' function
in handleSubmit:

@action('Edit', validator=my_validator)
def edit(self, **data):
        ...

As Fred Drake said:
"The validator is responsible for populating `data` with the valid
values.  That's definitely covered in the docs somewhere. "

There was some discussion about that in zope3-users list:
http://mail.zope.org/pipermail/zope3-users/2007-March/005934.html

So I think you're right about the name (which in fact is 'validator', I
misspelled this a bit)
but I think that current state is even worse because 'validator' is not
for validation in fact
but for populating with 'valid' data.

The real problem is where we can do validations (if it is not possible
to use invariants)
and where we can modify data just like in your case. I think that
function like 'validator',
maybe called 'prepare_data' or something, that would get 'data'
dictionary filled with values
would be really helpful.
Also few simple changes to ease validation and setting errors for
widgets would be helpful.
I've seen that Grok will bring some changes to formlib, but I don't know
exactly what will
be different. AFAIR applyChanges will be changed to different name.

-- 
Maciej Wisniowski

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

Reply via email to