From 4b330f3173eb0a3d82b743c73de6cf5c9ecd0178 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 31 Jul 2015 01:53:08 +0200 Subject: [PATCH] [FIX] http jump to database selector on broken databases --- openerp/http.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/openerp/http.py b/openerp/http.py index 128a9526568aa..6daf9f01a2441 100644 --- a/openerp/http.py +++ b/openerp/http.py @@ -1444,13 +1444,19 @@ def _dispatch_nodb(): try: with openerp.tools.mute_logger('openerp.sql_db'): ir_http = request.registry['ir.http'] - except (AttributeError, psycopg2.OperationalError): + except (AttributeError, psycopg2.OperationalError, psycopg2.ProgrammingError): # psycopg2 error or attribute error while constructing - # the registry. That means the database probably does - # not exists anymore or the code doesnt match the db. + # the registry. That means either + # - the database probably does not exists anymore + # - the database is corrupted + # - the database version doesnt match the server version # Log the user out and fall back to nodb request.session.logout() - result = _dispatch_nodb() + # If requesting /web this will loop + if request.httprequest.path == '/web': + result = werkzeug.utils.redirect('/web/database/selector') + else: + result = _dispatch_nodb() else: result = ir_http._dispatch() openerp.modules.registry.RegistryManager.signal_caches_change(db)