From 646a7de17a9b4702098483b7b3c2689fa9d6092e Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 21 Jan 2014 16:54:03 +0100 Subject: [PATCH 1/3] [MOV] move redirection headers from webclient to server bzr revid: fme@openerp.com-20140121155403-nmnntq664j2d1qjz --- openerp/http.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/openerp/http.py b/openerp/http.py index 03c8c999dde..35c7a3bd040 100644 --- a/openerp/http.py +++ b/openerp/http.py @@ -49,6 +49,27 @@ request = _request_stack() A global proxy that always redirect to the current request object. """ +def local_redirect(path, query=None, keep_hash=False, forward_debug=True, code=303): + url = path + if not query: + query = {} + if forward_debug and request and request.debug: + query['debug'] = None + if query: + url += '?' + werkzeug.url_encode(query) + if keep_hash: + return redirect_with_hash(url) + else: + return werkzeug.utils.redirect(url, code) + +def redirect_with_hash(url, code=303): + # Most IE and Safari versions decided not to preserve location.hash upon + # redirect. And even if IE10 pretends to support it, it still fails + # inexplicably in case of multiple redirects (and we do have some). + # See extensive test page at http://greenbytes.de/tech/tc/httpredirects/ + return "" % url + + class WebRequest(object): """ Parent class for all OpenERP Web request types, mostly deals with initialization and setup of the request object (the dispatching itself has From b5118e606edb34016ffad32568b1e02019cfd91e Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 21 Jan 2014 17:01:58 +0100 Subject: [PATCH 2/3] [FIX] redirect_with_hash firefox bug bzr revid: fme@openerp.com-20140121160158-qsy28zty51wg7ip4 --- openerp/http.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openerp/http.py b/openerp/http.py index 35c7a3bd040..5b49b8f22da 100644 --- a/openerp/http.py +++ b/openerp/http.py @@ -67,6 +67,8 @@ def redirect_with_hash(url, code=303): # redirect. And even if IE10 pretends to support it, it still fails # inexplicably in case of multiple redirects (and we do have some). # See extensive test page at http://greenbytes.de/tech/tc/httpredirects/ + if request.httprequest.user_agent.browser in ('firefox',): + return werkzeug.utils.redirect(url, code) return "" % url From fea85208895f63c6dc3d1c46b7005f0679e9f188 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 22 Jan 2014 11:40:22 +0100 Subject: [PATCH 3/3] [FIX] local_redirect() should forward code to redirect_with_hash() bzr revid: fme@openerp.com-20140122104022-hal3xe6eywffly3u --- openerp/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/http.py b/openerp/http.py index 285bdd751d3..f3431584807 100644 --- a/openerp/http.py +++ b/openerp/http.py @@ -58,7 +58,7 @@ def local_redirect(path, query=None, keep_hash=False, forward_debug=True, code=3 if query: url += '?' + werkzeug.url_encode(query) if keep_hash: - return redirect_with_hash(url) + return redirect_with_hash(url, code) else: return werkzeug.utils.redirect(url, code)