1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
24 def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False, pooljobs=True):
28 db = get_db_only(db_name)
30 if db_name in pool_dic:
31 pool = pool_dic[db_name]
33 import openerp.addons as addons
34 import openerp.osv.osv as osv_osv
35 pool = osv_osv.osv_pool()
36 pool_dic[db_name] = pool
39 addons.load_modules(db, force_demo, status, update_module)
46 pool.init_set(cr, False)
47 pool.get('ir.actions.report.xml').register_all(cr)
53 pool.get('ir.cron').restart(db.dbname)
57 def restart_pool(db_name, force_demo=False, status=None, update_module=False):
58 if db_name in pool_dic:
60 return get_db_and_pool(db_name, force_demo, status, update_module=update_module)
63 def get_db_only(db_name):
65 # do not put this import outside this function
66 # sql_db must not be loaded before the logger is initialized.
67 # sql_db import psycopg2.tool which create a default logger if there is not.
68 # this resulting of having the logs outputed twice...
69 import openerp.sql_db as sql_db
70 db = sql_db.db_connect(db_name)
75 return get_db_and_pool(db_name)[0]
78 def get_pool(db_name, force_demo=False, status=None, update_module=False):
79 pool = get_db_and_pool(db_name, force_demo, status, update_module)[1]
82 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: