On Wednesday, July 10, 2013 7:28:49 PM UTC-4, Mark Finkelstein wrote:

> I noticed that widget objects extending FormWidget are required to 
> implement widget(), but couldn't find a place where that function is used. 
> I was wondering what it would be for as it does not seem necessary for 
> implementing widgets.


The various widget classes are assigned to a Storage object, 
SQLFORM.widgets<https://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#857>.
 
The "widget" class methods are then used in this 
section<https://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#1064>of 
the SQLFORM code (e.g., self.widgets.boolean.widget).
 

> I was also wondering where validators are processed. I could not find 
> where, but going through process() I found it goes on to validate() and 
> onto accepts(), but nowhere did I find code checking the validators.
>

FORM.accepts calls the 
._traverse<https://code.google.com/p/web2py/source/browse/gluon/html.py#2014>method,
 which is then called 
recursively<https://code.google.com/p/web2py/source/browse/gluon/html.py#846>over
 the form DOM. The 
._validate<https://code.google.com/p/web2py/source/browse/gluon/html.py#853>method
 is then called, and when applied to widgets such as INPUT and 
SELECT, it applies the validators (e.g., INPUT 
validation<https://code.google.com/p/web2py/source/browse/gluon/html.py#1758>
).

For SQLFORMs, when the widgets are created for each field, the 
field.requires attribute is transferred to the 
widget<https://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#125>, 
so the validators become part of the widget (and are therefore processed 
when the widget's ._validate method is called, as described above).

So, as you can see, it's really all quite clear and straightforward. ;-)

Anthony

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to