> So while the behavior may seem a little odd, it let's you construct
> the validation scenarios you need.
Hmm... you're right.
So In fact for normalization and validation and in general preprocessing
we may use'validator' function like that (not tested):

def myactionvalidator(form, action, data):
     # fill data dictionary
     errors = form.validate(action, data)
     if errors:
         return errors

     # data dictionary is filled so it is possible
     # to normalize data or do other validation like:
     if data['field1']>123 and data['field2']<234:
         errors.append('something is wrong')

     # errors is either empty list (as returned by form.validate)
     # or list filled with errors
     # We shouldn't return None here because this would cause
     # form.validate to be called again in handleSubmit method
     return errors

I had one more issue with subclassing and actions.
If you're subclassing from a class that has some actions already defined
and you want to add new actions, eg. you want to have Edit form with
additional 'Cancel' action, then it is necessary to do something like

class MyNewEditForm(EditForm):
    actions = EditForm.actions


    def handler...

I mean line:
    actions = EditForm.actions

Otherwise 'Edit' action will be not available.

Not much to do to get inherited actions back but surprising...

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

Reply via email to