I suppose to override;

The example you gave would be pointless to have both;

Clearly if you define it once at the model; then again in the controller;

shouldn't the one define in the controller take precedence;

How else would you override?



On 3/23/11 11:45 AM, Jaunx 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.


Reply via email to