On Thursday, June 9, 2011 1:01:02 PM UTC-4, Vineet wrote: 
>
> Hi ! 
>
> Below given is a table --- 
> <code> 
> db.define_table('ac', 
>     Field('acnm','string', IS_LENGTH(100), length=100, required=True), 
>     Field('acgrpid', db.acgrp, notnull=True, required=True), 
>     Field('active', 'string', IS_LENGTH(1), length=1, 
> requires=IS_LENGHT(1), default='Y', required=True,  notnull=True), 
>     Field('homeunit', db.unit, notnull=True, required=True), 
>     Field('showall', 'string',IS_LENGTH(1), length=1, 
> requires=IS_LENGHT(1), default='Y', required=True, 
>     notnull=True), 
>     migrate=False 
>     ) 
> </code> 
>
> --- In the Field 'active', I have written --- required=True, 
> notnull=True. 
> From the documentation, the purpose of "required" is understood. 
> 1) But where does "notnull" come in action? (whether in AJAX 
> validation or while DAL inserts or somewhere else).

 
'required' is enforced by the DAL, and notnull is enforced by the database 
itself (it is equivalent to the "NOT NULL" SQL statement). Note, because 
notnull affects the actual database table, I think changing it requires 
migrations to be on.
 

>
> 2) For the Field 'active', I want to have a set of 2 values ('Y' & 
> 'N'). 
> In FORM, the user would be able to select a value from these 2 values 
> ONLY. (default is 'Y').

 
Use requires=IS_IN_SET(['Y','N']). In that case, you won't have to bother 
with IS_LENGTH.
 
Anthony
 

Reply via email to