diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 9a43513f0d5..7501aab3ad3 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -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): diff --git a/bin/osv/osv.py b/bin/osv/osv.py index 5c08a5ee636..87902b4b5eb 100644 --- a/bin/osv/osv.py +++ b/bin/osv/osv.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). 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: + diff --git a/bin/pooler.py b/bin/pooler.py index 8b5b3b2a865..0064e2397b6 100644 --- a/bin/pooler.py +++ b/bin/pooler.py @@ -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)