1 ##############################################################################
3 # Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
5 # WARNING: This program as such is intended to be used by professional
6 # programmers who take the whole responsability of assessing all potential
7 # consequences resulting from its eventual inadequacies and bugs
8 # End users who are looking for a ready-to-use solution with commercial
9 # garantees and support are strongly adviced to contract a Free Software
12 # This program is Free Software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 2
15 # of the License, or (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 ##############################################################################
37 def get_db_and_pool(db_name, force_demo=False, status={}, update_module=False):
41 logger = netsvc.Logger()
42 logger.notifyChannel('pooler', netsvc.LOG_INFO, 'Connecting to %s' % (db_name))
43 db = sql_db.db_connect(db_name)
46 if db_name in pool_dic:
47 pool = pool_dic[db_name]
49 pool = osv.osv.osv_pool()
50 pool_dic[db_name] = pool
51 addons.load_modules(db, force_demo, status, update_module)
54 report.interface.register_all(db)
56 pool.get('ir.cron')._poolJobs(db.dbname)
59 def restart_pool(db_name, force_demo=False, update_module=False):
62 return get_db_and_pool(db_name, force_demo, update_module=update_module)
64 def close_db(db_name):
66 db_dic[db_name].truedb.close()
68 if db_name in pool_dic:
71 def get_db_only(db_name):
75 db = sql_db.db_connect(db_name)
80 # print "get_db", db_name
81 return get_db_and_pool(db_name)[0]
83 def get_pool(db_name, force_demo=False, status={}, update_module=False):
84 # print "get_pool", db_name
85 pool = get_db_and_pool(db_name, force_demo, status, update_module)[1]
86 # addons.load_modules(db_name, False)
87 # if not pool.obj_list():
91 # return get_db_and_pool(db_name)[1]
95 # db = get_db_only(tools.config['db_name'])