[FIX] when a module can not be loaded, the pool is delete, allowing to recreate a new pool...

bzr revid: christophe@tinyerp.com-20090107145234-96rg0fq1jgwe9fcd
This commit is contained in:
Christophe Simonis 2009-01-07 15:52:34 +01:00
parent 91e2f84261
commit c56395453a
3 changed files with 21 additions and 11 deletions

View File

@ -317,11 +317,17 @@ def register_class(m):
"""
Register module named m, if not already registered
"""
def log(e):
mt = isinstance(e, zipimport.ZipImportError) and 'zip ' or ''
msg = "Couldn't load%s module %s" % (mt, m)
logger.notifyChannel('init', netsvc.LOG_CRITICAL, msg)
logger.notifyChannel('init', netsvc.LOG_CRITICAL, e)
global loaded
if m in loaded:
return
logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: registering objects' % m)
loaded.append(m)
mod_path = get_module_path(m)
try:
zip_mod_path = mod_path + '.zip'
@ -335,15 +341,11 @@ def register_class(m):
else:
zimp = zipimport.zipimporter(zip_mod_path)
zimp.load_module(m)
except zipimport.ZipImportError:
logger.notifyChannel('init', netsvc.LOG_CRITICAL, 'Couldn\'t find zip module %s' % m)
raise
except ImportError:
logger.notifyChannel('init', netsvc.LOG_CRITICAL, 'Couldn\'t find module %s' % m)
raise
except Exception:
logger.notifyChannel('init', netsvc.LOG_CRITICAL, 'Couldn\'t find module %s' % (m))
except Exception, e:
log(e)
raise
else:
loaded.append(m)
class MigrationManager(object):

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -261,3 +261,5 @@ class osv(orm.orm):
self.pool = pool
orm.orm.__init__(self, cr)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -35,7 +35,13 @@ def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False)
import osv.osv
pool = osv.osv.osv_pool()
pool_dic[db_name] = pool
addons.load_modules(db, force_demo, status, update_module)
try:
addons.load_modules(db, force_demo, status, update_module)
except Exception, e:
del pool_dic[db_name]
raise
cr = db.cursor()
try:
pool.init_set(cr, False)