[FIX] Fix bug in binary/image controller

bzr revid: fme@openerp.com-20120813135653-zvk21ch7dc9rs66w
This commit is contained in:
Fabien Meghazi 2012-08-13 15:56:53 +02:00
parent e543552dbd
commit 41791f7e2f
1 changed files with 4 additions and 4 deletions

View File

@ -1359,19 +1359,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()
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([int(id)], [last_update], context)[0].get(last_update)
date = Model.read([id], [last_update], context)[0].get(last_update)
if hashlib.md5(date).hexdigest() == etag:
return werkzeug.wrappers.Response(status=304)
retag = hashed_session
try:
id = None if not id else simplejson.loads(id)
if type(id) is list:
id = id[0] # m2o
if not id:
res = Model.default_get([field], context).get(field)
image_data = base64.b64decode(res)