- removed unnecessary call to openerp.modules.db.initialize() in openerp/service/web_services.py
as the pooler.restart_pool() call just next after is already doing it.
- made the try/finally section bigger in openerp/modules/loading.py, to inlcude
the first cr.execute.
- abstracted the test to check if a database is initialized.
- removed unnecessary "if cr:" as the cr is nevertheless used after that.
bzr revid: vmt@openerp.com-
20110517091822-pjtw6sc1s5assbr5
+def is_initialized(cr):
+ """ Check if a database has been initialized for the ORM.
+
+ The database can be initialized with the 'initialize' function below.
+
+ """
+ cr.execute("SELECT relname FROM pg_class WHERE relkind='r' AND relname='ir_module_module'")
+ return len(cr.fetchall()) > 0
+
def initialize(cr):
""" Initialize a database with for the ORM.
def initialize(cr):
""" Initialize a database with for the ORM.
+ force = []
+ if force_demo:
+ force.append('demo')
+
- if cr:
- cr.execute("SELECT relname FROM pg_class WHERE relkind='r' AND relname='ir_module_module'")
- if len(cr.fetchall())==0:
+ try:
+ if not openerp.modules.db.is_initialized(cr):
logger.notifyChannel("init", netsvc.LOG_INFO, "init db")
openerp.modules.db.initialize(cr)
tools.config["init"]["all"] = 1
tools.config['update']['all'] = 1
if not tools.config['without_demo']:
tools.config["demo"]['all'] = 1
logger.notifyChannel("init", netsvc.LOG_INFO, "init db")
openerp.modules.db.initialize(cr)
tools.config["init"]["all"] = 1
tools.config['update']['all'] = 1
if not tools.config['without_demo']:
tools.config["demo"]['all'] = 1
- force = []
- if force_demo:
- force.append('demo')
- # This is a brand new pool, just created in pooler.get_db_and_pool()
- pool = pooler.get_pool(cr.dbname)
+ # This is a brand new pool, just created in pooler.get_db_and_pool()
+ pool = pooler.get_pool(cr.dbname)
processed_modules = []
report = tools.assertion_report()
# NOTE: Try to also load the modules that have been marked as uninstallable previously...
processed_modules = []
report = tools.assertion_report()
# NOTE: Try to also load the modules that have been marked as uninstallable previously...
cr = None
try:
serv.actions[id]['progress'] = 0
cr = None
try:
serv.actions[id]['progress'] = 0
- cr = sql_db.db_connect(db_name).cursor()
- openerp.modules.db.initialize(cr)
tools.config['lang'] = lang
tools.config['lang'] = lang
- cr.commit()
- cr.close()
- cr = None
pool = pooler.restart_pool(db_name, demo, serv.actions[id],
update_module=True)[1]
pool = pooler.restart_pool(db_name, demo, serv.actions[id],
update_module=True)[1]