[FIX] sql_db: connection pool created lazily.

- This is necessary to give a chance to change the config just after importing openerp.

bzr revid: vmt@openerp.com-20110421103125-3lv609wnu3vh2m4f
This commit is contained in:
Vo Minh Thu 2011-04-21 12:31:25 +02:00
parent 2356412aea
commit 7008aa3e0e
1 changed files with 4 additions and 1 deletions

View File

@ -374,9 +374,12 @@ def dsn_are_equals(first, second):
return key(first) == key(second)
_Pool = ConnectionPool(int(tools.config['db_maxconn']))
_Pool = None
def db_connect(db_name):
global _Pool
if _Pool is None:
_Pool = ConnectionPool(int(tools.config['db_maxconn']))
currentThread().dbname = db_name
return Connection(_Pool, db_name)