# -*- encoding: utf-8 -*-
##############################################################################
#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False):
if not status:
status={}
-
+
db = get_db_only(db_name)
if db_name in pool_dic:
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:
+ del pool_dic[db_name]
+ raise
+
cr = db.cursor()
try:
pool.init_set(cr, False)
finally:
cr.close()
- if not update_module:
- import report
- report.interface.register_all(db)
- pool.get('ir.cron')._poolJobs(db.dbname)
+ import report
+ report.interface.register_all(db)
+ pool.get('ir.cron').restart(db.dbname)
return db, pool
-def restart_pool(db_name, force_demo=False, update_module=False):
- del pool_dic[db_name]
- return get_db_and_pool(db_name, force_demo, update_module=update_module)
+def restart_pool(db_name, force_demo=False, status=None, update_module=False):
+ if db_name in pool_dic:
+ del pool_dic[db_name]
+ return get_db_and_pool(db_name, force_demo, status, update_module=update_module)
def get_db_only(db_name):