[Zope3-Users] Re: formlib vs. cancel button

Martin Aspeli optilude at gmx.net
Thu Feb 15 11:46:18 EST 2007


Philipp von Weitershausen wrote:
> Martin Aspeli wrote:
>> Marius Gedminas wrote:
>>> On Thu, Feb 15, 2007 at 09:55:19AM +0000, Martin Aspeli wrote:
>>>> Dennis Schulz wrote:
>>>>> I dont know if it is the "proper" way,
>>>>> but when I return an empty string there is no validation error.
>>>>>
>>>>> This was also one of the strangest things I found out with formlib.....
>>>> I found that returning {} also works.
>>> The validator is supposed to return a list of errors.  Neither '' nor {}
>>> are lists.  () is a list.  I use
>>>
>>>     @form.action("Cancel", validator=lambda *a: ())
>>>     def cancel(self, action, data):
>>>         ...
>>>
>>>> But this is clearly a design weakness if there is no other way of 
>>>> doing it. Something like validator=NULL_VALIDATOR would be fine, or 
>>>> some kind of decorator.
>>> +1 for allowing
>>>
>>>     @form.action("Cancel", validator=form.no_validation)
>> I added something similar to plone.app.form, but there really, really 
>> should be support for this use case in formlib in a non-hacky way.
> 
> We happily accept patches through collector entries. Actually, aren't 
> you a committer? :)

No, not yet, paperwork scares me. And I'm looking into it. I'm just not 
quite sure I (want to) understand the full validation mechanism in 
formlib. We could obviously have such a null-validator in formlib itself 
for import. However, I wonder if it shouldn't be something a bit less 
hacky, e.g. a different type of decorator or some different option 
passwed to the @form.action decorator.

Martin



More information about the Zope3-users mailing list