models and controllers are not modules. models and controllers can import modules using "import <module>" if <module> is in sys.path and using "local_import(<module>)" if <module> is not in sys.path but is in /applications/app/modules.
modules are - of course - modules so thy can import other modules using "import <module>". They should not and cannot use "local_import" because that's only for models and controllers. Massimo On Dec 9, 8:47 am, John-Kim Murphy <left...@gmail.com> wrote: > I am trying to import a module 'pychimp' from another module 'inbite' > using local_import(). Both modules are in my modules directory. When I > nest a local_import() inside another local_import() I get an error: > > c...@inbite.py: > local_import('pychimp', reload=True) > > >>> inbite = local_import('inbite', reload=True) > > Traceback (most recent call last): > File "<console>", line 1, in <module> > File "gluon/compileapp.py", line 241, in <lambda> > File "gluon/compileapp.py", line 176, in local_import_aux > File "applications\inbite\modules\inbite.py", line 3, in <module> > NameError: name 'local_import' is not defined > > So I try importing the module that has local_import: > c...@inbite.py: > > import gluon.compileapp > > gluon.compileapp.local_import('pychimp', reload=True) > > >>> inbite = local_import('inbite', reload=True) > > Traceback (most recent call last): > File "<console>", line 1, in <module> > File "gluon/compileapp.py", line 241, in <lambda> > File "gluon/compileapp.py", line 176, in local_import_aux > File "applications\inbite\modules\inbite.py", line 4, in <module> > AttributeError: 'module' object has no attribute 'local_import' > > Unnested, it works fine: > > >>> pc = local_import('pychimp', reload=True) > > Also if I import like below it also seems to work fine, but I read it > is better to import modules from the app modules directory using > local_import(): > import applications.inbite.modules.pychimp as pychimp > > Can anyone tell me how to do nested local_import()? > > Thanks, > John