[IMP] openerp.modules.db: nice critical logging, and nice IOError exception
authorVo Minh Thu <vmt@openerp.com>
Fri, 16 Sep 2011 12:13:15 +0000 (14:13 +0200)
committerVo Minh Thu <vmt@openerp.com>
Fri, 16 Sep 2011 12:13:15 +0000 (14:13 +0200)
when the base.sql is not found.

bzr revid: vmt@openerp.com-20110916121315-lklf5nib8u1pztk5

openerp/modules/db.py

index 25ce728..86ba025 100644 (file)
@@ -21,6 +21,7 @@
 ##############################################################################
 
 import openerp.modules
+import logging
 
 def is_initialized(cr):
     """ Check if a database has been initialized for the ORM.
@@ -40,6 +41,10 @@ def initialize(cr):
 
     """
     f = openerp.modules.get_module_resource('base', 'base.sql')
+    if not f:
+        m = "File not found: 'base.sql' (provided by module 'base')."
+        logging.getLogger('init').critical(m)
+        raise IOError(m)
     base_sql_file = openerp.tools.misc.file_open(f)
     try:
         cr.execute(base_sql_file.read())