[web2py] Re: validating computed field

2012-02-20 Thread Anthony
On Monday, February 20, 2012 3:31:29 PM UTC-5, Alan Etkin wrote: > > Great! Thanks for your quick answer. I really don't understand > completely what does IS_NOT_IN_DB, I just copy/pasted the code and it > works perfectly. I'll check the documentation and the API for detailed > info. > The firs

[web2py] Re: validating computed field

2012-02-20 Thread Alan Etkin
Great! Thanks for your quick answer. I really don't understand completely what does IS_NOT_IN_DB, I just copy/pasted the code and it works perfectly. I'll check the documentation and the API for detailed info. Thanks again On 20 feb, 17:06, Anthony wrote: > > db.combinada.primero.requires = > >

[web2py] Re: validating computed field

2012-02-20 Thread Anthony
> > db.combinada.primero.requires = > [IS_NOT_IN_DB(db(db.combinada.combinado==str(request.vars.primero) > +str(request.vars.segundo)), "combinada.combinado"), IS_NOT_EMPTY()] > The value of request.vars.primero will be passed to the above IS_NOT_IN_DB validator, but it is then comparing that

[web2py] Re: validating computed field

2012-02-20 Thread Alan Etkin
I looked at the code posted in stackoverflow, but it's behaving the same as the former model, perhaps I am not implementing the example correctly: This is the new model: db.define_table("combinada", Field("combinado", requires=IS_NOT_EMPTY(), compute=lambda row: row.primero+row.segundo, unique=Tr

[web2py] Re: validating computed field

2012-02-20 Thread Anthony
One option is to use an "onvalidation" function with your form: http://web2py.com/books/default/chapter/29/7#onvalidation. In your onvalidation function, you can re-use the field's compute function by calling it with form.vars as its argument: def my_onvalidation(form): combinada = db.combi