Tuesday, June 7, 2011

Continuing the Web2py Module Saga

A web search reveals that modules were being imported wrong.  instead of the standard method, one should use the import_local() function as shown here.
A source code comment very clearly explains what to do:

 In apps, instead of importing a local module
    (in applications/app/modules) with::


       import a.b.c as d


    you should do::


       d = local_import('a.b.c')


    or (to force a reload):


       d = local_import('a.b.c', reload=True)


    This prevents conflict between applications and un-necessary execs.
    It can be used to import any module, including regular Python modules.

However, it does not work in our implementation.  I'm going to figure out what it does and why by reading the source code.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home