Comment 2 for bug 1256199

Revision history for this message
Med Said BARA (diassynthesis) wrote :

Hi;
I am also facing this situation, but it's just a WARNING.
Extarct from my log file:
2014-02-04 22:57:23,080 1683 INFO ? openerp: OpenERP version 7.0-20140204-002725
2014-02-04 22:57:23,085 1683 INFO ? openerp: addons paths: /usr/lib/pymodules/python2.7/openerp/addons
2014-02-04 22:57:23,085 1683 INFO ? openerp: database hostname: localhost
2014-02-04 22:57:23,087 1683 INFO ? openerp: database port: 5432
2014-02-04 22:57:23,087 1683 INFO ? openerp: database user: openerp
2014-02-04 22:57:23,106 1683 WARNING ? openerp.modules.module:
Ambiguous import: the OpenERP module `resource` is shadowed by another
module (available at /usr/lib/python2.7/lib-dynload/resource.so).
To import it, use `import openerp.addons.<module>.`.
2014-02-04 22:57:23,323 1948 INFO ? openerp.service.workers: Worker WorkerHTTP (1948) alive
2014-02-04 22:57:23,453 1952 INFO ? openerp.service.workers: Worker WorkerHTTP (1952) alive
2014-02-04 22:57:23,493 1958 INFO ? openerp.service.workers: Worker WorkerHTTP (1958) alive

As stated by Nhomar "resource" is a python standard library, and is dynamicaly loaded if it is in " ../pythonx.x/lib-dynload/ " directory (so that they can be loaded dynamically (at run time) into the interpreter), and Dynamically loaded extension modules loaded by Python are not unloaded.

So, i think this case is dealing with a relative import:
In many __init__.py files (under addons) we can find an " import resource" statement with a "resource.py" files in the same directory, and in this case it seems to me that the solution is to replace the "import" statement by " from openerp.addons.xxxxx import resource".

http://docs.python.org/2/c-api/init.html?highlight=dynamically%20loaded%20extension
http://www.python.org/dev/peps/pep-0302/
http://docs.python.org/2/reference/simple_stmts.html#import

But i'm not sure this is the solution (if someone else can investigate and confirm !!!).

Best regards