You are right. We can do this better but the only improvement would be
speed.

On May 27, 2:06 pm, Iceberg <iceb...@21cn.com> wrote:
> > > > On May 11, 1:08 pm,Iceberg<iceb...@21cn.com> wrote:
>
> > > > > Hi Massimo,
>
> > > > > Right now validators are triggered even when a record is successfully
> > > > > being deleted. This can be annoying in case I am deleting old records
> > > > > as below:
>
> > > > > db.define_table('my_table',
> > > > >     Field('today', 'date',
> > > > >         requires=IS_DATE_IN_RANGE(minimum=request.now.date()),
> > > > >         default = request.now.date(),
> > > > >         )
> > > > >     )
>
> > > > > What if we drop all the form.errors content before line 923 in gluon/
> > > > > sqlhtml.py?
> > > > >     if requested_delete:
> > > > >         ......
> > > > >         self.form.errors = {} # to override unnecessary error message
> > > > >         return True
>
> > > > > Or a better way is to do delete before validators are called. Can you
> > > > > do that?
>
> > > > > Regards,
> > > > >Iceberg
>
> On May27, 9:13pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
>
>
> > Posting a possible solution in trunk now.
> > in gluon/sqlhtml.py replace
>
> >         if requested_delete:
> >             ....
> >             return True
>
> > with
>
> >         if requested_delete:
> >             ....
> >             self.errors.clear()
> >             return True
>
> > let me know if it works for you.
>
> It works as expected. Good.
>
> On the other hand, like I said in the first post of this thread
> (quoted above), a better way is to do delete before validators are
> called. Right now all the real delete job are performed at line 911,
> after a potential early exit at line 905, this makes me a little
> nervous, "will the delete operation be unintentionally bypassed in
> some certain circumstance?"  But after all, so far so good. So you
> make the decision whether a refactor is needed here.

Reply via email to