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 FORM helper. The Example 33 was written more then 3 years ago and needs to be revised. Massimo On Mar 23, 10:45 am, Jaunx <[email protected]> wrote: > In Example 29 of the "Database Examples" of the Quick Examples > tutorial, the last line of the model definition file (db.py) puts the > following constraint on the purchases.quantity field: > > db.purchases.quantity.requires=IS_INT_IN_RANGE(0,10) > > In Example 33, the controller for the purchase form (forth line of the > buy method in database_examples.py) defines the following constraint > on the quantity: > > TR("Quantity:",INPUT(_type="text",_name="quantity",requires=IS_INT_IN_RANGE > (1,100))), > > When you actually test the example application, the form accepts > values between 1 and 99 inclusive and the database is updated with the > appropriate value. > > What is the point of the constraint in the model definition if it is > not enforced? Seems like the model would be the ideal place to set > this constraint so that it doesn't need to be repeated for every form > that uses it. However it would be nice to be able to override the > default per form if necessary.

