The formlib.EditForm dosen't catch all errors form widgets.

The following method catches only InputError:

def getWidgetsData(widgets, form_prefix, data):
    errors = []
    form_prefix += '.'

    for input, widget in widgets.__iter_input_and_widget__():
        if input and IInputWidget.providedBy(widget):
            name = _widgetKey(widget, form_prefix)

            if not widget.hasInput():
                raise interfaces.FormError("No input", name)

            try:
                data[name] = widget.getInputValue()
            except InputErrors, error:
                errors.append(error)

    return errors

How can I enhance the error handling for 
WrongContainedType or NotUnique which are ValueErrors?

Do I miss something or is it correct to improve the 
validation in this method. Or is there in general a mess
in the widget implementation and it's error handling.

Hm, is it correct how the sequence widget handles errors
in the getInputValue method?

e.g.
    def getInputValue(self):
        """Return converted and validated widget data.

        If there is no user input and the field is required, then a
        ``MissingInputError`` will be raised.

        If there is no user input and the field is not required, then
        the field default value will be returned.

        A ``WidgetInputError`` is raised in the case of one or more
        errors encountered, inputting, converting, or validating the data.
        """
        if self.hasInput():
            self.preserve_widgets = True
            sequence = self._type(self._generateSequence())
            if sequence != self.context.missing_value:
                self.context.validate(sequence)
            elif self.context.required:
                raise MissingInputError(self.context.__name__,
                                        self.context.title)
            return sequence
        raise MissingInputError(self.context.__name__, self.context.title)


and dosen't convert errors raised in 
*self.context.validate(sequence)* to a ValidationError (InputErrors) ?

Regards
Roger Ineichen
_____________________________
Projekt01 GmbH
www.projekt01.ch
Boesch 65
6331 H├╝nenberg
phone     +41 (0)41 781 01 78
mobile    +41 (0)79 340 52 32
fax       +41 (0)41 781 00 78
email [EMAIL PROTECTED]
_____________________________
END OF MESSAGE

_______________________________________________
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