[IMP] openerp.modules.db: nice critical logging, and nice IOError exception

when the base.sql is not found.

bzr revid: vmt@openerp.com-20110916121315-lklf5nib8u1pztk5
This commit is contained in:
Vo Minh Thu 2011-09-16 14:13:15 +02:00
parent 3db8df9e85
commit 20d7d05a60
1 changed files with 5 additions and 0 deletions

View 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())