1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
22 """ Functions kept for backward compatibility.
24 They are simple wrappers around a global RegistryManager methods.
29 import openerp.conf.deprecation
30 from openerp.modules.registry import RegistryManager
32 _logger = logging.getLogger(__name__)
34 def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False):
35 """Create and return a database connection and a newly initialized registry."""
36 assert openerp.conf.deprecation.openerp_pooler
37 _logger.warning('openerp.pooler.get_db_and_pool() is deprecated.')
38 registry = RegistryManager.get(db_name, force_demo, status, update_module)
39 return registry.db, registry
42 def restart_pool(db_name, force_demo=False, status=None, update_module=False):
43 """Delete an existing registry and return a database connection and a newly initialized registry."""
44 _logger.warning('openerp.pooler.restart_pool() is deprecated.')
45 assert openerp.conf.deprecation.openerp_pooler
46 registry = RegistryManager.new(db_name, force_demo, status, update_module)
47 return registry.db, registry
50 """Return a database connection. The corresponding registry is initialized."""
51 assert openerp.conf.deprecation.openerp_pooler
52 return get_db_and_pool(db_name)[0]
55 def get_pool(db_name, force_demo=False, status=None, update_module=False):
56 """Return a model registry."""
57 assert openerp.conf.deprecation.openerp_pooler
58 return get_db_and_pool(db_name, force_demo, status, update_module)[1]
60 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: