Hi Massimo, I just came up with a handy myapp/views/generic.load, and I wonder whether you will like to accept it as part of web2py scaffold. It is already self-documented.
<!-- Start of the generic.load --> {{ ''' With this generic.load file, you can use same action to serve two purposes. Example modified from http://www.web2py.com/AlterEgo/default/show/252: def index(): return { 'part1':'hello world', 'part2': LOAD( url=URL(r=request,f='auxiliary.load'), # Notice the ".load" extention ajax=True), } def auxiliary(): form=SQLFORM.factory(Field('name')) if form.accepts(request.vars): return {'': "Hello %s" % form.vars.name} return {'':form} # Need NOT to write it as "return form" any more! >From now on, single auxiliary() can serve two purposes: http://.../auxiliary.load serves as a raw component LOADed by other action http://.../auxiliary serves as a normal html page as usual # PS: Please keep all above explanation for people to know when and how to use it. # License: Public Domain # Author: Iceberg at 21cn dot com ''' }} {{ # Does NOT extend layout.html, purposely.}} {{response.headers['Content-Type']='text/html'}} {{if len(response._vars)==1 and not response._vars.keys()[0]:}} {{=BEAUTIFY(response._vars.values()[0])}} {{ # To bypass the silly colon }} {{else:}} {{=BEAUTIFY(response._vars)}} {{pass}}