>>     @form.action("Cancel", validator=None)
-1 from me

Currently above code is same as:
>>     @form.action("Cancel")

So I think this is a very common pattern that means:
do standard validation, do not use additional action validator.

In general there are two
validators. Action validator (one we are assigning in the
above code) and default validator of the form.

handleSubmit is responsible
for handling action submits and this looks like that:

def handleSubmit(actions, data, default_validate=None):
    for action in actions:
        if action.submitted():
            errors = action.validate(data)  # validator we want set to
                                            # None is used here
            if errors is None:
                errors = default_validate(action, data)
            return errors, action

So first action.validate is called:

    def validate(self, data):
        if self.validator is not None:  # THIS MAY BE NONE
            return self.validator(self.form, self, data)

and when there are no errors (None is returned) then default
validator is executed which is:

    def validate(self, action, data):
        return (getWidgetsData(self.widgets, self.prefix, data)
                + checkInvariants(self.form_fields, data))

I might be wrong somewhere, so somebody better check this :)

Maciej Wisniowski
Zope3-users mailing list

Reply via email to