Commit 995a0479 authored by Ivan Tyagov's avatar Ivan Tyagov Committed by Julien Muchembled

Cache Bag is similar to Cache Factory so updateCache call is required.

Add back wrongly removed volatile conversion caching.
Use new set / get Cache bag API.
parent 5e966f01
......@@ -1128,7 +1128,8 @@ class ObjectTemplateItem(BaseTemplateItem):
container._mapTransform(obj)
elif obj.meta_type in ('ERP5 Ram Cache',
'ERP5 Distributed Ram Cache',):
assert container.meta_type == 'ERP5 Cache Factory'
assert container.meta_type in ('ERP5 Cache Factory',
'ERP5 Cache Bag')
container.getParentValue().updateCache()
elif (container.meta_type == 'CMF Skins Tool') and \
(old_obj is not None):
......
......@@ -184,7 +184,12 @@ class CachedConvertableMixin:
# get preferred cache factory or cache bag
cache_factory = self._getCacheFactory()
if cache_factory is not None:
# volatile case
if cache_factory is None:
return getattr(aq_base(self), 'temp_conversion_data', {})[cache_id]
else:
data_dict = cache_factory.get(cache_id, None)
if data_dict:
if isinstance(data_dict, tuple):
......
......@@ -265,9 +265,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
document.convert(**kw)
cache_id = document._getCacheKey(**kw)
cache_factory = document._getCacheFactory()
for cache_plugin in cache_factory.getCachePluginList():
cache_entry = cache_plugin.get(cache_id, DEFAULT_CACHE_SCOPE)
data_dict = cache_entry.getValue()
data_dict = cache_factory.get(cache_id)
#get data from cache
self.assertTrue(data_dict['content_md5'])
self.assertTrue(data_dict['conversion_md5'])
......@@ -277,7 +275,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
self.assertTrue(data_dict['size'])
#Change md5 manualy
data_dict['content_md5'] = 'Anything which is not md5'
cache_plugin.set(cache_id, DEFAULT_CACHE_SCOPE, data_dict, 100, 0)
cache_factory.set(cache_id, data_dict)
self.commit()
self.assertRaises(KeyError, document.getConversion, format='html')
......
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