1 ##############################################################################
3 # Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved.
7 # WARNING: This program as such is intended to be used by professional
8 # programmers who take the whole responsability of assessing all potential
9 # consequences resulting from its eventual inadequacies and bugs
10 # End users who are looking for a ready-to-use solution with commercial
11 # garantees and support are strongly adviced to contract a Free Software
14 # This program is Free Software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License
16 # as published by the Free Software Foundation; either version 2
17 # of the License, or (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ###############################################################################
38 def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False):
44 logger = netsvc.Logger()
45 logger.notifyChannel('pooler', netsvc.LOG_INFO, 'Connecting to %s' % (db_name))
46 db = sql_db.db_connect(db_name)
49 if db_name in pool_dic:
50 pool = pool_dic[db_name]
52 pool = osv.osv.osv_pool()
53 pool_dic[db_name] = pool
54 addons.load_modules(db, force_demo, status, update_module)
58 report.interface.register_all(db)
59 pool.get('ir.cron')._poolJobs(db.dbname)
62 def restart_pool(db_name, force_demo=False, update_module=False):
65 return get_db_and_pool(db_name, force_demo, update_module=update_module)
67 def close_db(db_name):
69 db_dic[db_name].truedb.close()
71 if db_name in pool_dic:
74 def get_db_only(db_name):
78 db = sql_db.db_connect(db_name)
83 # print "get_db", db_name
84 return get_db_and_pool(db_name)[0]
86 def get_pool(db_name, force_demo=False, status=None, update_module=False):
87 # print "get_pool", db_name
88 pool = get_db_and_pool(db_name, force_demo, status, update_module)[1]
89 # addons.load_modules(db_name, False)
90 # if not pool.obj_list():
94 # return get_db_and_pool(db_name)[1]
98 # db = get_db_only(tools.config['db_name'])