[Zope3-Users] how to use invariant/validator? (z3c.form=1.6 and
z3c.formui=1.3)
Michael Howitz
mh at gocept.com
Fri Sep 21 02:38:35 EDT 2007
Am 19.09.2007 um 12:49 schrieb Mail_fuer_Kai at gmx.de:
> Hi,
>
> I want to use an invariant-check in an analogous manner like it is
> described at the end of the message.
> There is answered that the bug is fixed, but the same causes are
> still active.
> I'm using z3c.form=1.6 and z3c.formui=1.3
> What seems to be the trouble now?
>
> my code:
> class IAddressSearch(zope.interface.Interface):
> ...
> @zope.interface.invariant
> def firstnameOrSurname( search ):
> #import pdb; pdb.set_trace()
> if search.firstname == None:
> search.firstname = u''
> if search.surname == None:
> search.surname = u''
> if len(search.firstname) == 0 and len(search.surname) == 0:
> raise zope.interface.Invalid( u"""Enter firstname and/
> or surname.""")
>
>
> result of my Code:
> TypeError: tuple indices must be integers
Hi, can you please include a complete traceback to see where the
exception occurres?
--
Yours sincerely,
Michael Howitz
gocept gmbh & co. kg · forsterstrasse 29 · 06112 halle/saale
www.gocept.com · fon: +49 345 12298898 · fax: +49 345 12298891
More information about the Zope3-users
mailing list