BASE QUESTION:  What does "required=true" in the DAL actually do?
Could someone describe a "real-life" scenario where the use of this
setting/command would be useful or necessary?


In the course of trying make sure that a user doesn't leave an
important column blank on an input form, the issue of "required=true"
vs. requires came up.

I eventually achieved my goal with the following validator and
"requires".

db_bosswalk.BW_dept_info.Dept_id.requires=IS_NOT_EMPTY
(error_message='Dept ID cannot be blank!')


However.... while exploring "required=true", I came to the conclusion
that this feature just didn't really seem to do ANYTHING
constructive.... at least using SQL Server for the database.

Whether it was specified (or not), I could not get the app to act
differently when attempting to add a record where the Dept_id column
was left blank.

Here's the Model line for that column:
    SQLField('Dept_id', 'string', length=6, required=True), #varchar
(6)


I scoured the web2py manual and these online forums, but there's not
much else written on this topic other than the fragments below.

Page 138 of web2py manual:

"required" tells the DAL that no insert should be allowed on this
table if a
value for this field is not explicitly specified."


Page 139 of web2py manual:

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 ondelete are 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.

*********************************
Here's an explanation that makes this matter somewhat confusing to my
traditional line of thought.   If ANY value in the input box (null,
blank, numeric, string) is okay, then what is the true role of this
setting/command/feature?????

http://groups.google.com/group/web2py/browse_thread/thread/d9cab03764df1eed/f936dc821c88c149?lnk=gst&q=%22required%3Dtrue%22#f936dc821c88c149

If a field is required, it does not
matter what value it has (it can be null unless notnull=True) but,
if
it does not have a default, it must be set.

Thanks!

Todd B.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to