[Zope-dev] z3c.form: Customer errors for Converter errors
Hermann Himmelbauer
dusty at qwer.tk
Tue Sep 23 11:04:35 EDT 2008
Hi,
I'm currently trying to modify the error message for converter errors in
z3c.form. For instance, if I have an Int() field and input characters there,
the message is:
The entered value is not a valid integer literal.
So, I'd like to write a message such as "Please enter numbers only".
I tried now to register a custom error class like this:
------------------------
IntErrorMsg = error.ErrorViewMessage(
u'Please enter numbers only.',
error=zope.schema.ValidationError, field=IPerson['personnumber'])
zope.component.provideAdapter(IntErrorMsg, name='message')
------------------------
The problem with this is, that the error I need to create the error class for,
seems to be a zope.schema.ValidationError. This way, all errors are reported
with the error class above, which is bad.
So, is there a more specific error class for converter errors (I could not
find one)? Or is there a better way to solve my problem?
Best Regards,
Hermann
--
hermann at qwer.tk
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7
More information about the Zope-Dev
mailing list