From 85d568184c8a6e5022b686ce4449c64cbf9de19c Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 2 Jul 2013 12:33:31 +0200 Subject: [PATCH] [FIX] http: db_monodb returns a result when only one db is available bzr revid: mat@openerp.com-20130702103331-2f2vkz12sp385ldt --- addons/web/http.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/addons/web/http.py b/addons/web/http.py index 0c2bb1e3744..7acadc11fbc 100644 --- a/addons/web/http.py +++ b/addons/web/http.py @@ -35,6 +35,7 @@ import urllib2 import openerp import openerp.service.security as security +from openerp.tools import config import inspect import functools @@ -1121,21 +1122,18 @@ def db_monodb(): if db_url: return db_url - try: - dbs = db_list() - except Exception: - # ignore access denied - dbs = [] + dbs = db_list(True) # 2 use the database from the cookie if it's listable and still listed cookie_db = request.httprequest.cookies.get('last_used_database') if cookie_db in dbs: db = cookie_db - # 3 use the first db - if dbs and not db: + # 3 use the first db if user can list databases + if dbs and not db and (config['list_db'] or len(dbs) == 1): db = dbs[0] - return db.lower() if db else db + + return db class JsonRpcController(Controller):