[IMP] openerp.addons: openerp.addons is used instead of

openerp.modules as the namespace of the OpenERP addons.

bzr revid: vmt@openerp.com-20120109124120-06gguu3lzxv49i3j
This commit is contained in:
Vo Minh Thu 2012-01-09 13:41:20 +01:00
parent 1560538f8a
commit 455e47e5e8
4 changed files with 11 additions and 11 deletions

View File

@ -244,7 +244,7 @@ if __name__ == "__main__":
def find_module(self, module_name, package_path):
module_parts = module_name.split('.')
if len(module_parts) == 3 and module_name.startswith('openerp.modules.'):
if len(module_parts) == 3 and module_name.startswith('openerp.addons.'):
return self # We act as a loader too.
# TODO list of loadable modules can be cached instead of always
@ -259,18 +259,18 @@ if __name__ == "__main__":
logger.warning("""
Ambiguous import: the OpenERP module `%s` is shadowed by another
module (available at %s).
To import it, use `import openerp.modules.<module>.`.""" % (module_name, path))
To import it, use `import openerp.addons.<module>.`.""" % (module_name, path))
return
except ImportError, e:
# Using `import <module_name>` instead of
# `import openerp.modules.<module_name>` is ugly but not harmful
# `import openerp.addons.<module_name>` is ugly but not harmful
# and kept for backward compatibility.
return self # We act as a loader too.
def load_module(self, module_name):
module_parts = module_name.split('.')
if len(module_parts) == 3 and module_name.startswith('openerp.modules.'):
if len(module_parts) == 3 and module_name.startswith('openerp.addons.'):
module_part = module_parts[2]
if module_name in sys.modules:
return sys.modules[module_name]
@ -286,7 +286,7 @@ if __name__ == "__main__":
is_shadowing = True
except ImportError, e:
# Using `import <module_name>` instead of
# `import openerp.modules.<module_name>` is ugly but not harmful
# `import openerp.addons.<module_name>` is ugly but not harmful
# and kept for backward compatibility.
is_shadowing = False
@ -295,7 +295,7 @@ if __name__ == "__main__":
mod = imp.load_module(module_name, f, path, descr)
if not is_shadowing:
sys.modules[module_part] = mod
sys.modules['openerp.modules.' + module_part] = mod
sys.modules['openerp.addons.' + module_part] = mod
return mod
openerp.modules.module.initialize_sys_path()

View File

@ -25,7 +25,7 @@
This module serves to contain all OpenERP addons, across all configured addons
paths. For the code to manage those addons, see openerp.modules.
Addons are made available under `openerp.modules` after
Addons are made available under `openerp.addons` after
openerp.tools.config.parse_config() is called (so that the addons paths are
known).

View File

@ -314,7 +314,7 @@ def register_module_classes(m):
try:
zip_mod_path = mod_path + '.zip'
if not os.path.isfile(zip_mod_path):
__import__('openerp.modules.' + m)
__import__('openerp.addons.' + m)
else:
zimp = zipimport.zipimporter(zip_mod_path)
zimp.load_module(m)

View File

@ -608,13 +608,13 @@ class MetaModel(type):
super(MetaModel, self).__init__(name, bases, attrs)
return
# The (OpenERP) module name can be in the `openerp.modules` namespace
# The (OpenERP) module name can be in the `openerp.addons` namespace
# or not. For instance module `sale` can be imported as
# `openerp.modules.sale` (the good way) or `sale` (for backward
# `openerp.addons.sale` (the good way) or `sale` (for backward
# compatibility).
module_parts = self.__module__.split('.')
if len(module_parts) > 2 and module_parts[0] == 'openerp' and \
module_parts[1] == 'modules':
module_parts[1] == 'addons':
module_name = self.__module__.split('.')[2]
else:
module_name = self.__module__.split('.')[0]