Hello,

I would clarify my understanding a bit... In the book it says :

Notice that requires=... is enforced at the level of forms, required=True is
enforced at the level of the DAL (insert), while notnull, unique and
ondeleteare enforced at the level of the database. While they sometimes may
seem redundant, it is important to maintain the distinction when programming
with the DAL.

So, here my sql (postgres) :

CREATE TABLE table1
(
  table1_id serial NOT NULL,
  result1 integer NOT NULL,
  result2 numeric(10,2) NOT NULL,
  seizure_date date NOT NULL,
  CONSTRAINT table1_id PRIMARY KEY (table1_id),
)


My web2py model should be :

db.define_table('table1',
    Field('table1_id','id'),
    Field('result1','integer',
                        notnull=True,
                        requires=IS_NOT_EMPTY(),
                        required=IS_NOT_EMPTY()),
    Field('result2','decimal(10,2)',
                        notnull=True,
                        requires=IS_NOT_EMPTY(),
                        required=IS_NOT_EMPTY()),
    Field('seizure_date','date',
                        readable=False,
                        writable=False,
                        default=request.now,
                        notnull=True,
                        requires=IS_NOT_EMPTY(),
                        required=IS_NOT_EMPTY()),
    migrate=False,
    sequence_name='table1_table1_id_seq')

notnull= generate the NOT NULL constraint of the sql script generated by
web2py?
requires= tell the validator to trigger on blank submit field?
required= tell the DAL to not pass a empty field to de database?

Thanks

Richard

Reply via email to