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
33 def ensure_registries():
35 if _Registries is None:
36 _Registries = RegistryManager()
39 def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False, pooljobs=True):
40 """Create and return a database connection and a newly initialized registry."""
42 bound_registry = _Registries.get(db_name, force_demo, status, update_module, pooljobs)
43 return bound_registry.db, bound_registry.registry
46 def delete_pool(db_name):
47 """Delete an existing registry."""
49 _Registries.delete(db_name)
52 def restart_pool(db_name, force_demo=False, status=None, update_module=False):
53 """Delete an existing registry and return a database connection and a newly initialized registry."""
55 bound_registry = _Registries.new(db_name, force_demo, status, update_module, True)
56 return bound_registry.db, bound_registry.registry
60 """Return a database connection. The corresponding registry is initialized."""
61 return get_db_and_pool(db_name)[0]
64 def get_pool(db_name, force_demo=False, status=None, update_module=False):
65 """Return a model registry."""
66 return get_db_and_pool(db_name, force_demo, status, update_module)[1]
68 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: