Commit 2954bf46 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

remove updateConversionCache() that does just make a needless access to cache plugins.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28370 20353a03-c40f-0410-a6d1-a30d3c3de9de
...@@ -152,22 +152,6 @@ class ConversionCacheMixin: ...@@ -152,22 +152,6 @@ class ConversionCacheMixin:
for cache_plugin in self._getCacheFactory().getCachePluginList(): for cache_plugin in self._getCacheFactory().getCachePluginList():
cache_plugin.delete(self.getPath(), DEFAULT_CACHE_SCOPE) cache_plugin.delete(self.getPath(), DEFAULT_CACHE_SCOPE)
security.declareProtected(Permissions.View, 'updateConversionCache')
def updateConversionCache(self):
"""
"""
if self.isTempObject():
if getattr(aq_base(self), 'temp_conversion_data', None) is None:
self.temp_conversion_data = {}
return
cache_factory = self._getCacheFactory()
cache_duration = cache_factory.cache_duration
for cache_plugin in cache_factory.getCachePluginList():
cache_plugin.initCacheStorage()
if not cache_plugin.has_key(self.getPath(), DEFAULT_CACHE_SCOPE):
cache_dict = {}
cache_plugin.set(self.getPath(), DEFAULT_CACHE_SCOPE, cache_dict, cache_duration=cache_duration)
security.declareProtected(Permissions.View, 'hasConversion') security.declareProtected(Permissions.View, 'hasConversion')
def hasConversion(self, **kw): def hasConversion(self, **kw):
""" """
...@@ -198,20 +182,20 @@ class ConversionCacheMixin: ...@@ -198,20 +182,20 @@ class ConversionCacheMixin:
def setConversion(self, data, mime=None, calculation_time=None, **kw): def setConversion(self, data, mime=None, calculation_time=None, **kw):
""" """
""" """
self.updateConversionCache()
cache_id = self.generateCacheId(**kw) cache_id = self.generateCacheId(**kw)
if self.isTempObject(): if self.isTempObject():
temp_conversion_cache = getattr(aq_base(self), 'temp_conversion_data') if getattr(aq_base(self), 'temp_conversion_data', None) is None:
temp_conversion_cache[cache_id] = (mime, aq_base(data)) self.temp_conversion_data = {}
self.temp_conversion_cache[cache_id] = (mime, aq_base(data))
return return
cache_factory = self._getCacheFactory() cache_factory = self._getCacheFactory()
cache_duration = cache_factory.cache_duration cache_duration = cache_factory.cache_duration
if data is not None: if data is not None:
for cache_plugin in cache_factory.getCachePluginList(): for cache_plugin in cache_factory.getCachePluginList():
if cache_plugin.has_key(self.getPath(), DEFAULT_CACHE_SCOPE): try:
cache_entry = cache_plugin.get(self.getPath(), DEFAULT_CACHE_SCOPE) cache_entry = cache_plugin.get(self.getPath(), DEFAULT_CACHE_SCOPE)
cache_dict = cache_entry.getValue() cache_dict = cache_entry.getValue()
else: except KeyError:
cache_dict = {} cache_dict = {}
cache_dict.update({cache_id: (mime, aq_base(data))}) cache_dict.update({cache_id: (mime, aq_base(data))})
cache_plugin.set(self.getPath(), DEFAULT_CACHE_SCOPE, cache_plugin.set(self.getPath(), DEFAULT_CACHE_SCOPE,
...@@ -222,11 +206,9 @@ class ConversionCacheMixin: ...@@ -222,11 +206,9 @@ class ConversionCacheMixin:
def getConversion(self, **kw): def getConversion(self, **kw):
""" """
""" """
self.updateConversionCache()
cache_id = self.generateCacheId(**kw) cache_id = self.generateCacheId(**kw)
if self.isTempObject(): if self.isTempObject():
temp_conversion_cache = getattr(aq_base(self), 'temp_conversion_data') return getattr(aq_base(self), 'temp_conversion_data', {})[cache_id]
return temp_conversion_cache[cache_id]
for cache_plugin in self._getCacheFactory().getCachePluginList(): for cache_plugin in self._getCacheFactory().getCachePluginList():
cache_entry = cache_plugin.get(self.getPath(), DEFAULT_CACHE_SCOPE) cache_entry = cache_plugin.get(self.getPath(), DEFAULT_CACHE_SCOPE)
data = cache_entry.getValue().get(cache_id) data = cache_entry.getValue().get(cache_id)
......
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