summaryrefslogtreecommitdiff
path: root/bin/pooler.py
diff options
context:
space:
mode:
authorChristophe Simonis <christophe@tinyerp.com>2008-12-08 15:03:42 +0100
committerChristophe Simonis <christophe@tinyerp.com>2008-12-08 15:03:42 +0100
commit299627a14408ce297277d2adfce2e4bdffa1fcbc (patch)
tree68be4ebcda06f61fcb95f09b81c54bf19e4ecf9e /bin/pooler.py
parente80211fbc32919212bb99beef79f6b45534a9445 (diff)
[IMP] use psycopg2 instead of psycopg1
bzr revid: christophe@tinyerp.com-20081208140342-qstsqxm0xr5rppzz
Diffstat (limited to 'bin/pooler.py')
-rw-r--r--bin/pooler.py54
1 files changed, 11 insertions, 43 deletions
diff --git a/bin/pooler.py b/bin/pooler.py
index c838641f01d..132e99b5089 100644
--- a/bin/pooler.py
+++ b/bin/pooler.py
@@ -20,30 +20,19 @@
#
##############################################################################
-import sql_db
-import osv.osv
-import tools
-import addons
-import netsvc
-
-db_dic = {}
pool_dic = {}
-
def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False):
if not status:
status={}
- if db_name in db_dic:
- db = db_dic[db_name]
- else:
- logger = netsvc.Logger()
- logger.notifyChannel('pooler', netsvc.LOG_INFO, 'Connecting to %s' % (db_name.lower()))
- db = sql_db.db_connect(db_name)
- db_dic[db_name] = db
+
+ db = get_db_only(db_name)
if db_name in pool_dic:
pool = pool_dic[db_name]
else:
+ import addons
+ import osv.osv
pool = osv.osv.osv_pool()
pool_dic[db_name] = pool
addons.load_modules(db, force_demo, status, update_module)
@@ -60,49 +49,28 @@ def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False)
def restart_pool(db_name, force_demo=False, update_module=False):
-# del db_dic[db_name]
del pool_dic[db_name]
return get_db_and_pool(db_name, force_demo, update_module=update_module)
-def close_db(db_name):
- if db_name in db_dic:
- db_dic[db_name].truedb.close()
- del db_dic[db_name]
- if db_name in pool_dic:
- del pool_dic[db_name]
-
-
def get_db_only(db_name):
- if db_name in db_dic:
- db = db_dic[db_name]
- else:
- db = sql_db.db_connect(db_name)
- db_dic[db_name] = db
+ # ATTENTION:
+ # do not put this import outside this function
+ # sql_db must not be loaded before the logger is initialized.
+ # sql_db import psycopg2.tool which create a default logger if there is not.
+ # this resulting of having the logs outputed twice...
+ import sql_db
+ db = sql_db.db_connect(db_name)
return db
def get_db(db_name):
-# print "get_db", db_name
return get_db_and_pool(db_name)[0]
def get_pool(db_name, force_demo=False, status=None, update_module=False):
-# print "get_pool", db_name
pool = get_db_and_pool(db_name, force_demo, status, update_module)[1]
-# addons.load_modules(db_name, False)
-# if not pool.obj_list():
-# pool.instanciate()
-# print "pool", pool
return pool
-# return get_db_and_pool(db_name)[1]
-
-
-def init():
- global db
-# db = get_db_only(tools.config['db_name'])
- sql_db.init()
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: