AW: AW: [Zope3-Users] z3c.form - howto ignore the context for singlewidgets in an Edit form?

Roger Ineichen dev at projekt01.ch
Sun Feb 10 13:39:44 EST 2008


Hi Christophe
 
> Betreff: Re: AW: [Zope3-Users] z3c.form - howto ignore the 
> context for singlewidgets in an Edit form?

[...]
> > class ISubscribeSchema(zope.interface.Interface):
> >     """The subscription form."""
> > 
> >     password = zope.schema.Password(
> >         title=_(u'Password'),
> >         description=_(u'The password for the applicant.'),
> >         required=True)
> > 
> >     confirm = zope.schema.Password(
> >         title=_(u'Confirm password'),
> >         description=_(u'The password for the principal.'),
> >         required=True)
> > 
> >     @zope.interface.invariant
> >     def confirmPassword(task):
> >         if task.password != task.confirm:
> >             raise zope.interface.Invalid(
> >                 _("Password doesn't compare with password 
> confirmation."))
> >         if len(task.password) < 6:
> >             raise zope.interface.Invalid(
> >                 _("Password must be at least 6 characters long."))
> > 
> > class SubcriptionForm/form.Form):
> >     """Subscription form."""
> > 
> >     ignoreContext = True
> > 
> >     fields = field.Fields(ISubscribeSchema)

[...]

> On the other hand, the password is already used in the 
> definition of the Principal (ex: in IInternalPrincipal), so 
> you get overlapping definitions of the password, and you need 
> to explicitly omit() the Principal password in the form generation.
> Or maybe you think it's better to use different schemas for 
> the Principal itself and for the subscription?

Yes, I think using a different schema for password confirmation 
is the right concept. This let us define a invariant in the schema too.
Both the invariant and the confirmation field are not a part of 
the (real) data model. Of corse that's not the only one solution,
but most of the time this works very well. It also allows you to
use a very simple form implementation  without any magic widgets
etc.

Regards
Roger Ineichen
_____________________________
END OF MESSAGE



More information about the Zope3-users mailing list