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