From c4c17fc3d201cc96ff00941015d90afcb5da3964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 28 May 2013 15:05:26 +0200 Subject: [PATCH] [FIX] image controller: all reads (event __last_update) should be encapsulated into a try/catch to avoid having sometimes a placeholder, sometimes a broken image + traceback. bzr revid: tde@openerp.com-20130528130526-iwzw5jjttr4nevc4 --- addons/web/controllers/main.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 117c14a2866..bfa69cd0528 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1217,19 +1217,19 @@ class Binary(openerpweb.Controller): headers = [('Content-Type', 'image/png')] etag = req.httprequest.headers.get('If-None-Match') hashed_session = hashlib.md5(req.session_id).hexdigest() + retag = hashed_session id = None if not id else simplejson.loads(id) if type(id) is list: id = id[0] # m2o - if etag: - if not id and hashed_session == etag: - return werkzeug.wrappers.Response(status=304) - else: - date = Model.read([id], [last_update], req.context)[0].get(last_update) - if hashlib.md5(date).hexdigest() == etag: - return werkzeug.wrappers.Response(status=304) - - retag = hashed_session try: + if etag: + if not id and hashed_session == etag: + return werkzeug.wrappers.Response(status=304) + else: + date = Model.read([id], [last_update], req.context)[0].get(last_update) + if hashlib.md5(date).hexdigest() == etag: + return werkzeug.wrappers.Response(status=304) + if not id: res = Model.default_get([field], req.context).get(field) image_base64 = res