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.
28 from openerp.modules.registry import RegistryManager
31 def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False, pooljobs=True):
32 """Create and return a database connection and a newly initialized registry."""
33 registry = RegistryManager.get(db_name, force_demo, status, update_module, pooljobs)
34 return registry.db, registry
37 def delete_pool(db_name):
38 """Delete an existing registry."""
39 RegistryManager.delete(db_name)
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 registry = RegistryManager.new(db_name, force_demo, status, update_module, True)
45 return registry.db, registry
49 """Return a database connection. The corresponding registry is initialized."""
50 return get_db_and_pool(db_name)[0]
53 def get_pool(db_name, force_demo=False, status=None, update_module=False):
54 """Return a model registry."""
55 return get_db_and_pool(db_name, force_demo, status, update_module)[1]
57 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: