Importing from modules works with absolute import , you must use

 import applications.yourappname.modules.modulename

The path has been set to the directory that web2py is running in - where the 
web2py.py file is.
Sent from my BlackBerry® smartphone on the MTS High Speed Mobility Network

-----Original Message-----
From: pierreth <[email protected]>
Sender: [email protected]
Date: Wed, 6 Apr 2011 07:39:47 
To: web2py-users<[email protected]>
Reply-To: [email protected]
Subject: [web2py] Re: Modularity

Here are my conclusion on using the "modules" directory.

What is working:

- Using local_import avoid collisions of modules or packages that may
have the same names in other applications.
- Explicit and implicit relative imports are working well for modules
located in the "modules" directory.

What is not working:

- Absolute imports does not work because "modules" is not in the
Python path.

What this mean in practice:

- Modules located in "modules" can import each other if there are not
located in a package. This is implicit relative import.
- local_import is working well with both modules and packages.
- Modules located in "modules", regardless of if they are or not
located in a package, can only import other modules located both in a
package and in "modules" using explicit relative imports. Absolute
imports only work for modules and packages located in the Python path.

So if you drop both a module "a" depending on module "b" in "modules",
they will probably work very well. But if you drop both a package "a"
depending on package "b" (or a module "b"), it will probably not work.
Using relative imports in this case is not the norm. Inter packages
dependencies will not work in "modules". Is this a bug?

See: http://docs.python.org/tutorial/modules.html#packages

I suggest to add this message to the web2py book.

Reply via email to