The documentation says, in section 6.17.4 (my highlighting):

1 {{extend 'layout.html'}}
> 2 <h1>Records</h1>
> 3 {{=SQLTABLE(rows)}}
>
 

SQLTABLE converts the rows into an HTML table with a header containing the
> column names and one row per record. ... 

The values extracted from the database are also formatted by the validators
> associated to the field and then escaped. (Note: Using a db in this way 
> in a
> view is usually not considered good MVC practice.)


I assume the doc means that validators shouldn't be used in a model file, 
as the formatting that gets done as a result should be done by the view. Or 
they should be used in a model file, but it's unfortunate that the 
formatting gets done as a result, as opposed to being done in the view.

1. Is my assumption correct? If not, then why is this "not considered good 
MVC practice"?

2. So what should be done in my web2py code, then? Add the validators in 
the controller code? Or is this just something we live with as web2py 
developers?

Thanks.

-- 



Reply via email to