Andrea Riciputi
2009-03-04 09:57:40 UTC
Hi,
I'm pretty new to Formencode, so please forgive my inexperience.
I'm trying to make htmlfill to put the error message raised by a
chained validator near a specific form field.
To get this I've written a custom validator where the messages dict is
defined like this:
messages = {'my_error_label': u"Error message goes here" }
then, if the conditions are not met I raise the Invalid exception like
this:
raise Invalid(self.message('my_error_label', state),
values, state,
error_dict={
'my_error_label': Invalid(self.message('field_name', state), values,
state)
})
Despite the fact this gives me the expected result, I'm not sure I'm
raising that exception in the correct way. I mean, I got the
impression that the Invalid instance could be called in easier way,
but I really can't see how. Any suggestion?
TIA,
Andrea
I'm pretty new to Formencode, so please forgive my inexperience.
I'm trying to make htmlfill to put the error message raised by a
chained validator near a specific form field.
To get this I've written a custom validator where the messages dict is
defined like this:
messages = {'my_error_label': u"Error message goes here" }
then, if the conditions are not met I raise the Invalid exception like
this:
raise Invalid(self.message('my_error_label', state),
values, state,
error_dict={
'my_error_label': Invalid(self.message('field_name', state), values,
state)
})
Despite the fact this gives me the expected result, I'm not sure I'm
raising that exception in the correct way. I mean, I got the
impression that the Invalid instance could be called in easier way,
but I really can't see how. Any suggestion?
TIA,
Andrea