[MERGE] addons import hook: give precedence to our own modules, let them shadow other Python modules.
bzr revid: vmt@openerp.com-20120210094812-7lewrxwpqfrlmke1
This commit is contained in:
commit
602a931ae4
|
@ -101,10 +101,9 @@ class AddonsImportHook(object):
|
|||
# Check if the bare module name clashes with another module.
|
||||
f, path, descr = imp.find_module(module_parts[0])
|
||||
_logger.warning("""
|
||||
Ambiguous import: the OpenERP module `%s` is shadowed by another
|
||||
module (available at %s).
|
||||
To import it, use `import openerp.addons.<module>.`.""" % (module_name, path))
|
||||
return
|
||||
Ambiguous import: the OpenERP module `%s` is shadowing another
|
||||
module (available at %s).""" % (module_name, path))
|
||||
return self # We act as a loader too.
|
||||
except ImportError, e:
|
||||
# Using `import <module_name>` instead of
|
||||
# `import openerp.addons.<module_name>` is ugly but not harmful
|
||||
|
@ -137,7 +136,7 @@ To import it, use `import openerp.addons.<module>.`.""" % (module_name, path))
|
|||
# Note: we don't support circular import.
|
||||
f, path, descr = imp.find_module(module_part, ad_paths)
|
||||
mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)
|
||||
if not is_shadowing:
|
||||
if is_shadowing or not is_shadowing: # == if True, but keep the defined variable.
|
||||
sys.modules[module_part] = mod
|
||||
for k in sys.modules.keys():
|
||||
if k.startswith('openerp.addons.' + module_part):
|
||||
|
|
Loading…
Reference in New Issue