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