[Zope3-Users] Re: Invariants and forms
Maciej Wisniowski
maciej.wisniowski at coig.katowice.pl
Tue Aug 14 07:07:58 EDT 2007
> The standard error message is:
> There were errors
>
'There were errors' is default 'status message' when there are some errors.
Do you have any custom template in use?
Please, take a look at:
zope/formlib/form.py
around line 717 there is 'update' function that is interesting for you:
def update(self):
self.setUpWidgets()
self.form_reset = False
data = {}
errors, action = handleSubmit(self.actions, data, self.validate)
self.errors = errors
if errors:
self.status = _('There were errors')
result = action.failure(data, errors)
elif errors is not None:
self.form_reset = True
result = action.success(data)
else:
result = None
self.form_result = result
As you can see there is a call to 'handleSubmit' which in turn calls
validation function, that calls function to check invariants.
As a result in 'errors' list you should have your error message
from invariants. Seems for me that this message is there
because self.status is set to 'There were errors' (so 'errors'
list is not empty).
'errors' list is used by ZPT: pageform.pt to display errors by default.
That's why I asked if you have custom template...
If above doesn't help then... do you know 'pdb'?
I think you should use pdb to debug code and see what happens.
Just put line:
import pdb;pdb.set_trace()
into above 'update' method from 'form.py' after a call to handleSubmit
and check what is in errors list.
Read about pdb here:
http://plone.org/documentation/how-to/using-pdb
--
Maciej Wisniowski
More information about the Zope3-users
mailing list