When I add --dynamic-load=DEMO_.* to the __main__.py script file  like so:

TARGETS = {
   'Showcase.py': dict(path='src', options=['--dynamic-load=DEMO_.*']),
}

the application compiles, and loads all the pyjamas.*.js files but then 
tries to download files such as 
pyjamas.ui.pyjamas.js, pyjamas.sys.js, and pyjamas.ui.sys.js, but receive a 
404 error (which they should)..

I'm compiling the DEMO_* files on my own in the compile.py script, but 
these fail to import properly with the __import__ statement..

Any advice?

Thanks!


On Monday, September 3, 2012 6:23:55 AM UTC-5, Billy Earney wrote:
>
> Thanks..  That is very helpful.
>
> On Sunday, September 2, 2012 1:12:55 PM UTC-5, C Anthony Risinger wrote:
>>
>> On Sat, Sep 1, 2012 at 5:31 PM, Billy Earney <[email protected]> 
>> wrote: 
>> > I'm trying to modify the examples (ie, showcase) to load the examples 
>> by 
>> > section (other, panels, widgets) by using the dynamic module  and 
>> > specifically the ajax_import function.   I'm compiling the python demos 
>> by 
>> > using a modified compile.py script which creates 3 separate demo files. 
>> > Really all I'm doing is splitting up the demos into 3 files that will 
>> be 
>> > loaded dynamically when a user opens up one of the branches in the 
>> tree. 
>> > My reasoning for this, is that it takes quite a while to load the 
>> current 
>> > showcase example, and the gwt showcase version seems to use some type 
>> of 
>> > dynamic loading.  I believe this will speed up the initial loading of 
>> the 
>> > application. 
>> > 
>> > What changes need to be made to the output of the showcase compile.py 
>> script 
>> > to use it with dynamic.ajax_import ? 
>>
>> bleh i forgot the showcase had that compile.py stuff ... i had to 
>> special case it whenever i used it (website/etc.) 
>>
>> i would not try to use the ajax/dynamic stuff directly ... simply 
>> prefix all the generated modules with some unique string, say 
>> `example_` or `demo_`, then build the application with: 
>>
>> pyjsbuild ... --dynamic-load=REGEX ... 
>>
>> ... where REGEX would be a PCRE matching your prefix: 
>>
>> example_.* 
>> demo_.* 
>>
>> ... this tells the linker to skip those modules and instead load them 
>> using synchronous XHR at runtime, on-demand. 
>>
>> this stuff should work today, OOTB.  if not, it's a bug. 
>>
>> the only thing you need to ensure, is that the modules are NOT loaded 
>> on boot ... this usually means putting the import statements in a 
>> function (eg. NOT at module level): 
>>
>> def import_example_1(): 
>>     import example_1 
>>     example_1.show() 
>>
>> def import_example(ident): 
>>     __import__(ident) 
>>     ident = sys.modules[ident] 
>>     ident.show() 
>>
>> ... or something similar. 
>>
>> -- 
>>
>> C Anthony 
>>
>

-- 



Reply via email to