Is this issue closed? I cannot reproduce the problem.
On Apr 11, 12:25 pm, Jens Örtenholm <jens.ortenh...@gmail.com> wrote: > Are we talking about different approaches here? > > I am now certain I did something wrong the first time around. I made a simple > test as follows: > > In db.py: > > db.define_table('people', > Field('name', 'string')) > > In people.py (controller): > > def func(form): > session.flash = T('Onvalidation called') > > def index(): > form = SQLFORM(db.people) > if form.accepts(request.vars, session, onvalidation=func): > pass > return dict(form=form) > > I get the flash every time I submit the form, so the function is definitely > called. Also, if I try to replace it with an undeclared function, I get a > ticket with NameError: global name 'undeclaredfunc' is not defined. > > Tried with and without regular validators in the table definition. Only case > where the onvalidation function is not called is when one of the regular > validators does not validate. > > I also did verify it works when updating a record, atleast with this simple > example. > > Regards, > Jens Örtenholm > jens.ortenh...@gmail.com > > 11 apr 2011 kl. 16.40 skrev VP: > > > > > > > > > I have checked again and inserted an undeclared function call into the > > custom validator and figured out that it is not called at all. > > > Something is wrong. > > > On Apr 8, 9:52 am, Massimo Di Pierro <massimo.dipie...@gmail.com> > > wrote: > >> This may be a bug. Will look into it... > > >> On Apr 8, 2:31 am, Jens Örtenholm <jens.ortenh...@gmail.com> wrote: > > >>> Hello everyone, > > >>> I believe I've found a bug in SQLFORM.accepts. > > >>> When calling with an onvalidation function as: > > >>> form = SQLFORM(db.table) > >>> if form.accepts(request.vars, session, onvalidation=function): > > >>> And the function sets an error: > > >>> def function(form): > >>> form.errors.myfield = 'This is an error' > > >>> The form is still accepted, DB is inserted or updated with the record. > > >>> As far as I can tell from looking at the code in SQLFORM.accepts, the case > >>> where ret value is False because of form.errors not being empty is not > >>> handled anywhere. > > >>> Tested on 1.94.6 > > >>> //Jens