I am wondering what are the issues to be considered when deciding where to 
generate a form. Is it better to do so in the controller or in the view? Or is 
it just a matter of personal preference?

An example code snippet is show below. Given that first() and second() actions 
generates identical forms, is it better to generate the form in some_view.html, 
instead of in the controller, considering efficiency and DRY?

===============================
# some_view.html

{{=some_form}}

# first.html
{{ extend some_view.html }}

# second.html
{{ extend some_view.html }}

#default.py
def first():
    ...
    some_form = #SQLFORM code
    ...
    return {'some_form':some_form}

def second():
    ...
    some_form = #SQLFORM code  
    ...
    return {'some_form':some_form}

=========================


      

Reply via email to