[FIX] loading: load base only once.
bzr revid: vmt@openerp.com-20110902132712-j9bgfnzbmddarr7h
This commit is contained in:
parent
3c8571ead0
commit
79d0e39c4c
|
@ -158,7 +158,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules=
|
||||||
logger.info('module %s: loading objects', package.name)
|
logger.info('module %s: loading objects', package.name)
|
||||||
migrations.migrate_module(package, 'pre')
|
migrations.migrate_module(package, 'pre')
|
||||||
register_module_classes(package.name)
|
register_module_classes(package.name)
|
||||||
models = pool.instanciate(package.name, cr)
|
models = pool.load(cr, package)
|
||||||
loaded_modules.append(package.name)
|
loaded_modules.append(package.name)
|
||||||
if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'):
|
if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'):
|
||||||
init_module_models(cr, package.name, models)
|
init_module_models(cr, package.name, models)
|
||||||
|
@ -273,8 +273,6 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
|
||||||
# This is a brand new pool, just created in pooler.get_db_and_pool()
|
# This is a brand new pool, just created in pooler.get_db_and_pool()
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
|
|
||||||
processed_modules = [] # for cleanup step after install
|
|
||||||
loaded_modules = [] # to avoid double loading
|
|
||||||
report = tools.assertion_report()
|
report = tools.assertion_report()
|
||||||
if 'base' in tools.config['update'] or 'all' in tools.config['update']:
|
if 'base' in tools.config['update'] or 'all' in tools.config['update']:
|
||||||
cr.execute("update ir_module_module set state=%s where name=%s and state=%s", ('to upgrade', 'base', 'installed'))
|
cr.execute("update ir_module_module set state=%s where name=%s and state=%s", ('to upgrade', 'base', 'installed'))
|
||||||
|
@ -285,8 +283,10 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
|
||||||
if not graph:
|
if not graph:
|
||||||
logger.notifyChannel('init', netsvc.LOG_CRITICAL, 'module base cannot be loaded! (hint: verify addons-path)')
|
logger.notifyChannel('init', netsvc.LOG_CRITICAL, 'module base cannot be loaded! (hint: verify addons-path)')
|
||||||
raise osv.osv.except_osv(_('Could not load base module'), _('module base cannot be loaded! (hint: verify addons-path)'))
|
raise osv.osv.except_osv(_('Could not load base module'), _('module base cannot be loaded! (hint: verify addons-path)'))
|
||||||
loaded, processed = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report)
|
|
||||||
processed_modules.extend(processed)
|
# processed_modules: for cleanup step after install
|
||||||
|
# loaded_modules: to avoid double loading
|
||||||
|
loaded_modules, processed_modules = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report)
|
||||||
|
|
||||||
if tools.config['load_language']:
|
if tools.config['load_language']:
|
||||||
for lang in tools.config['load_language'].split(','):
|
for lang in tools.config['load_language'].split(','):
|
||||||
|
|
|
@ -65,14 +65,21 @@ class Registry(object):
|
||||||
""" Return a model for a given name or raise KeyError if it doesn't exist."""
|
""" Return a model for a given name or raise KeyError if it doesn't exist."""
|
||||||
return self.models[model_name]
|
return self.models[model_name]
|
||||||
|
|
||||||
def instanciate(self, module, cr):
|
def load(self, cr, module):
|
||||||
""" Instanciate all the classes of a given module for a particular db."""
|
""" Load a given module in the registry.
|
||||||
|
|
||||||
|
At the Python level, the modules are already loaded, but not yet on a
|
||||||
|
per-registry level. This method populates a registry with the given
|
||||||
|
modules, i.e. it instanciates all the classes of a the given module
|
||||||
|
and registers them in the registry.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
|
|
||||||
# Instantiate registered classes (via metamodel discovery or via explicit
|
# Instantiate registered classes (via metamodel discovery or via explicit
|
||||||
# constructor call), and add them to the pool.
|
# constructor call), and add them to the pool.
|
||||||
for cls in openerp.osv.orm.MetaModel.module_to_models.get(module, []):
|
for cls in openerp.osv.orm.MetaModel.module_to_models.get(module.name, []):
|
||||||
res.append(cls.createInstance(self, cr))
|
res.append(cls.createInstance(self, cr))
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
Loading…
Reference in New Issue