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 ##############################################################################
36 def get_db_and_pool(db_name, force_demo=False, status={}, update_module=False):
40 print 'Pooler Connecting to', db_name
41 db = sql_db.db_connect(db_name)
44 if db_name in pool_dic:
45 pool = pool_dic[db_name]
47 pool = osv.osv.osv_pool()
48 pool_dic[db_name] = pool
49 addons.load_modules(db, force_demo, status, update_module)
52 report.interface.register_all(db)
54 pool.get('ir.cron')._poolJobs(db.dbname)
57 def restart_pool(db_name, force_demo=False, update_module=False):
60 return get_db_and_pool(db_name, force_demo, update_module=update_module)
62 def close_db(db_name):
64 db_dic[db_name].truedb.close()
66 if db_name in pool_dic:
69 def get_db_only(db_name):
73 db = sql_db.db_connect(db_name)
78 # print "get_db", db_name
79 return get_db_and_pool(db_name)[0]
81 def get_pool(db_name, force_demo=False, status={}, update_module=False):
82 # print "get_pool", db_name
83 pool = get_db_and_pool(db_name, force_demo, status, update_module)[1]
84 # addons.load_modules(db_name, False)
85 # if not pool.obj_list():
89 # return get_db_and_pool(db_name)[1]
93 # db = get_db_only(tools.config['db_name'])