X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=openerp%2Fpooler.py;h=88b60864b904dd1850d1cb26b925d95b6ddbe2c3;hb=23068e6afb63c172936eb70f7cce608c4dcaa338;hp=78eec82b59e0a09aee2238e8142a7b2c28d22545;hpb=67aa6c461a757da0ab6c5fc9d9f5f06895a4e65b;p=odoo%2Fodoo.git diff --git a/openerp/pooler.py b/openerp/pooler.py index 78eec82..88b6086 100644 --- a/openerp/pooler.py +++ b/openerp/pooler.py @@ -19,66 +19,34 @@ # ############################################################################## -import sql_db +""" Functions kept for backward compatibility. -pool_dic = {} + They are simple wrappers around a global RegistryManager methods. -def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False, pooljobs=True): - """Return a database connection and an initialized osv_pool.""" - if not status: - status={} - - db = sql_db.db_connect(db_name) - - if db_name in pool_dic: - pool = pool_dic[db_name] - else: - import openerp.modules - import openerp.osv.osv as osv_osv - pool = osv_osv.osv_pool() +""" - # Initializing an osv_pool will call general code which will in turn - # call get_db_and_pool (this function) to obtain the osv_pool begin - # initialized. Make it available in the pool_dic then remove it if - # an exception is raised. - pool_dic[db_name] = pool - try: - openerp.modules.load_modules(db, force_demo, status, update_module) - except Exception: - del pool_dic[db_name] - raise +from openerp.modules.registry import RegistryManager - cr = db.cursor() - try: - pool.init_set(cr, False) - pool.get('ir.actions.report.xml').register_all(cr) - cr.commit() - finally: - cr.close() - - if pooljobs: - pool.get('ir.cron').restart(db.dbname) - return db, pool +def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False, pooljobs=True): + """Create and return a database connection and a newly initialized registry.""" + registry = RegistryManager.get(db_name, force_demo, status, update_module, pooljobs) + return registry.db, registry -def delete_pool(db_name): - """Delete an existing osv_pool.""" - if db_name in pool_dic: - del pool_dic[db_name] def restart_pool(db_name, force_demo=False, status=None, update_module=False): - """Delete an existing osv_pool and return a database connection and a newly initialized osv_pool.""" - delete_pool(db_name) - return get_db_and_pool(db_name, force_demo, status, update_module=update_module) + """Delete an existing registry and return a database connection and a newly initialized registry.""" + registry = RegistryManager.new(db_name, force_demo, status, update_module, True) + return registry.db, registry def get_db(db_name): - """Return a database connection. The corresponding osv_pool is initialize.""" + """Return a database connection. The corresponding registry is initialized.""" return get_db_and_pool(db_name)[0] def get_pool(db_name, force_demo=False, status=None, update_module=False): - """Return an osv_pool.""" + """Return a model registry.""" return get_db_and_pool(db_name, force_demo, status, update_module)[1] # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: