I'm using a form with form validator.
When validation error occurs on a page I'd like to log this event along
with ip-address from which a request was made. The problem with this is
that validator knows nothing about request and form has no error info
from validator. My current code is this:
formProcessed, data = self.processForm()
if data == 'invalid':
forms = self.formDefinitions()
form = forms['Login']
fv = form._formValidators
message = fv.errorMessage # set by validator
addr = self.request().remoteAddress()
log.warn("Login from %s failed: %s", addr, message)
Is there any better way to achieve this?
Best way, imho, would be to make self.processForm() method return error
info from validator.