[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
This commit is contained in:
Thibault Delavallée 2013-05-28 15:05:26 +02:00
parent 3b6d5aede2
commit c4c17fc3d2
1 changed files with 9 additions and 9 deletions

View File

@ -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