Commit edfbdf6b authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Arnaud Fontaine

py2/py3: Base64 encode inventory cache, as Shared.DC.ZRDB.DA.SQL tries to...

py2/py3: Base64 encode inventory cache, as Shared.DC.ZRDB.DA.SQL tries to decode bytes to str (nexedi/erp5!1751).
parent 15219e6d
......@@ -63,6 +63,7 @@ from hashlib import md5
from warnings import warn
from six.moves.cPickle import loads, dumps
from copy import deepcopy
import base64
import six
MYSQL_MIN_DATETIME_RESOLUTION = 1/86400.
......@@ -1439,7 +1440,7 @@ class SimulationTool(BaseTool):
if src__:
sql_source_list.append(Resource_zGetInventoryCacheResult(src__=1, **inventory_cache_kw))
if cached_sql_result:
brain_result = loads(cached_sql_result[0].result)
brain_result = loads(base64.b64decode(cached_sql_result[0].result))
# Rebuild the brains
cached_result = Results(
(brain_result['items'], brain_result['data']),
......@@ -1488,10 +1489,10 @@ class SimulationTool(BaseTool):
self.Resource_zInsertInventoryCacheResult(
query=sql_text_hash,
date=cached_date,
result=dumps({
result=base64.b64encode(dumps({
'items': result.__items__,
'data': result._data,
}),
})),
)
else:
# Cache miss and this getInventory() not specifying to_date,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment