[Zope3-Users] z3c.form: how to use invariant/validator?

Darryl Cousins darryl at darrylcousins.net.nz
Sun Aug 12 06:29:15 EDT 2007


Hi,

Invariant now works as expected with your new code. Thanks.

Regards,
Darryl

On Tue, 2007-08-07 at 23:38 -0400, Stephan Richter wrote:
> On Monday 06 August 2007 22:23, Stephan Richter wrote:
> > On Sunday 05 August 2007 16:51, Peter Piehler wrote:
> > > recently I started working with Zope3 and z3c.form.
> > > The figures in the form should be checked, for instance that the first
> > > name and the surname are not identical. Therefore I write an
> > > invariant-check:
> > >
> > > class IAddress(zope.interface.Interface):
> > >     """Address Interface"""
> > >     ...
> > >     @zope.interface.invariant
> > >     def areEqual( address ):
> > >         if address.firstname == address.surname:
> > >             raise zope.interface.Invalid(u"first name and surname are
> > > same")
> > >
> > > I was expecting that the error would be shown in the form.
> > > Unfortunately, zope canceled the  action:
> >
> > Hi Peter,
> >
> > just a quick note to tell you that I am not ignoring you. I have just
> > reproduced the problem in a doctest and I am fixing it now. I'll send
> > another mail, once I checked in a fix.
> 
> Hi Peter,
> 
> I just checked in a fix for this problem into z3c.form and z3c.formui. It 
> actually turned out that I had to fix2 bugs and add a feature to solve the 
> problem. But it should be working now.
> 
> I did not make a new release yet, but will do that soon too.
> 
> Please let me know, if it is still not working!
> 
> Regards,
> Stephan



More information about the Zope3-users mailing list