[web2py] Re: IS_INT_IN_RANGE Behavior in Database Example

2011-03-24 Thread DenesL
On Mar 23, 12:29 pm, Massimo Di Pierro wrote: > Thins constraint > > >   db.purchases.quantity.requires=IS_INT_IN_RANGE(0,10) > > is enforced in > > form=crud.create(db.purchases) > form=crud.update(db.purchases,record) > form=SQLFORM(db.purchases) > form=SQLFORM.factory(...,db.purchases.quantit

[web2py] Re: IS_INT_IN_RANGE Behavior in Database Example

2011-03-24 Thread Massimo Di Pierro
Nope. It was added in 1.94.something On Mar 23, 2011, at 4:45 PM, Anthony wrote: > On Wednesday, March 23, 2011 5:33:45 PM UTC-4, Massimo Di Pierro wrote: > 2) if you want the check done in insert you can call > db.table.validate_and_insert > > How long has that been around? I don't think it's

[web2py] Re: IS_INT_IN_RANGE Behavior in Database Example

2011-03-23 Thread niknok
re validate_insert I think it's a custom function. Read back the post made by Massimo about a week ago ... On Mar 24, 5:45 am, Anthony wrote: > On Wednesday, March 23, 2011 5:33:45 PM UTC-4, Massimo Di Pierro wrote: > > > 2) if you want the check done in insert you can call > > db.table.validate

[web2py] Re: IS_INT_IN_RANGE Behavior in Database Example

2011-03-23 Thread Anthony
On Wednesday, March 23, 2011 5:33:45 PM UTC-4, Massimo Di Pierro wrote: > > 2) if you want the check done in insert you can call > db.table.validate_and_insert How long has that been around? I don't think it's in the book, is it?

[web2py] Re: IS_INT_IN_RANGE Behavior in Database Example

2011-03-23 Thread Massimo Di Pierro
There are two reason it is done this way: 1) one reason is that if a check fails there must be a way to report to the users. Forms have a mechanism for this but db.table.insert does not, in general 2) if you want the check done in insert you can call db.table.validate_and_insert 3) there is no way

[web2py] Re: IS_INT_IN_RANGE Behavior in Database Example

2011-03-23 Thread Jaunx
Logically -- without much web2py familiarity -- I would think that the constraints specified in the model would be be applied absolutely anywhere the model is used. So when you have a constraint like in the example model: db.purchases.quantity.requires=IS_INT_IN_RANGE(0,10) The model would pre

[web2py] Re: IS_INT_IN_RANGE Behavior in Database Example

2011-03-23 Thread villas
If I undertood correctly, you expect the model to have priority over any other validation constraints. This is not how it works in web2py. You may override validations at any point and my experience is that it is very useful to do so. If you wish to enforce a DB constraint which could not be ov

[web2py] Re: IS_INT_IN_RANGE Behavior in Database Example

2011-03-23 Thread Massimo Di Pierro
Thins constraint >   db.purchases.quantity.requires=IS_INT_IN_RANGE(0,10) is enforced in form=crud.create(db.purchases) form=crud.update(db.purchases,record) form=SQLFORM(db.purchases) form=SQLFORM.factory(...,db.purchases.quantity,...) It is not enforced in forms built manually, like HTML and