Am Sonntag, 10. Februar 2008 19:39 schrieb Roger Ineichen: > 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.
Yes, although a confirmation widget looked appealing at first, I also agree with Roger now and implemented this similar as shown above. Back to z3c.formwidget: What do you think should this package exactly contain: - Only widgets? - Combinations of schemas and widgets? - Also schemas without widgets (like an Email schema that inherits from a TextLine and thus uses a TextWidget)? Best Regards, Hermann -- [EMAIL PROTECTED] GPG key ID: 299893C7 (on keyservers) FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7 _______________________________________________ Zope3-users mailing list Zope3firstname.lastname@example.org http://mail.zope.org/mailman/listinfo/zope3-users