Does adding to response.files within a component controller work at all? 
With ajax=False, it looks like LOAD creates a new environment (and response) 
to run the component controller, so I'm not sure appending to response.files 
within a component controller will affect the response.files of the parent 
controller.
 
response.files is only used by web2py_ajax.html, which is typically included 
in layout.html. Your index view probably extends layout.html, so 
response.files added within the index controller will get included by 
web2py_ajax.html. However, your component .load views probably do not extend 
layout.html, so I would guess response.files added within component 
controllers would be ignored.
 
Haven't tried it, though, so I may be missing something.
 
Anthony

On Saturday, May 7, 2011 9:52:27 AM UTC-4, Iceberg wrote:

> Hi Massimo, 
>
> Can web2py support chaining response.files inside a component? 
>
> Scenario. 
>
> def component(): 
>     response.files.extend([ 
>         URL(..., 'fancy_helper1.js'), 
>         URL(..., 'fancy_helper2.js'), 
>         ......, 
>         URL(..., 'fancy_helper10.js'), 
>         ]) 
>     return {'': 'Some fancy stuff'} 
>
> def skeleton(): 
>     response.files.extend([ 
>         URL(..., 'fancy_helper1.js'), 
>         URL(..., 'fancy_helper2.js'), 
>         ......, 
>         URL(..., 'fancy_helper10.js'), 
>         ]) # SAME AS THOSE IN component(). Can I omit this? 
>     return {'': LOAD('default', 'component.load', ajax=False)} 
>
> def index(): 
>     response.files.extend([ 
>         URL(..., 'fancy_helper1.js'), 
>         URL(..., 'fancy_helper2.js'), 
>         ......, 
>         URL(..., 'fancy_helper10.js'), 
>         ]) # SAME AS THOSE IN component(). Can I omit this? 
>     return {'': LOAD('default', 'skeleton.load', ajax=False)} 
>
>
> Currently, if I add one more helper_extra.js into my fancy 
> component(), I needed to duplicate them into skeleton() and index(). 
> It is not DRY. Can it be improved? 
>
> Regards, 
> Ray Luo (Iceberg)

Reply via email to