[Erp5-report] r34878 nicolas - in /erp5/trunk/products/ERP5: Document/ interfaces/ mixin/
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Apr 30 11:26:37 CEST 2010
Author: nicolas
Date: Fri Apr 30 11:26:34 2010
New Revision: 34878
URL: http://svn.erp5.org?rev=34878&view=rev
Log:
* Delete clearConversionCache from API.
* Compute new cache key with revision (incremental counter based on
edit transtions of edit_workflow)
Modified:
erp5/trunk/products/ERP5/Document/File.py
erp5/trunk/products/ERP5/Document/TextDocument.py
erp5/trunk/products/ERP5/interfaces/document.py
erp5/trunk/products/ERP5/mixin/cached_convertable.py
Modified: erp5/trunk/products/ERP5/Document/File.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/File.py?rev=34878&r1=34877&r2=34878&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/File.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/File.py [utf8] Fri Apr 30 11:26:34 2010
@@ -131,7 +131,6 @@
getcontentlength = get_size
def _setFile(self, data, precondition=None):
- self.clearConversionCache()
CMFFile._edit(self, precondition=precondition, file=data)
security.declareProtected(Permissions.ModifyPortalContent,'setFile')
@@ -170,7 +169,6 @@
security.declareProtected(Permissions.ModifyPortalContent,'PUT')
def PUT(self, REQUEST, RESPONSE):
- self.clearConversionCache()
CMFFile.PUT(self, REQUEST, RESPONSE)
# DAV Support
Modified: erp5/trunk/products/ERP5/Document/TextDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TextDocument.py?rev=34878&r1=34877&r2=34878&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TextDocument.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TextDocument.py [utf8] Fri Apr 30 11:26:34 2010
@@ -124,13 +124,6 @@
security.declareProtected( Permissions.ModifyPortalContent, 'edit' )
edit = WorkflowMethod( _edit )
-
- security.declareProtected(Permissions.ModifyPortalContent, '_setTextContent')
- def _setTextContent(self, *args, **kw):
- """Call Clear conversion cache when edit text_content
- """
- self.clearConversionCache()
- self._baseSetTextContent(*args, **kw)
# Default Display
security.declareProtected(Permissions.View, 'index_html')
Modified: erp5/trunk/products/ERP5/interfaces/document.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/interfaces/document.py?rev=34878&r1=34877&r2=34878&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/interfaces/document.py [utf8] (original)
+++ erp5/trunk/products/ERP5/interfaces/document.py [utf8] Fri Apr 30 11:26:34 2010
@@ -233,11 +233,6 @@
links (in combindation with populate).
"""
- def clearConversionCache():
- """Clear cache (invoked by interaction workflow upon file upload
- needed here to overwrite class attribute with instance attrs
- """
-
def hasConversion(**kw):
"""Return a boolean if conversion is cached
"""
Modified: erp5/trunk/products/ERP5/mixin/cached_convertable.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/mixin/cached_convertable.py?rev=34878&r1=34877&r2=34878&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/mixin/cached_convertable.py [utf8] (original)
+++ erp5/trunk/products/ERP5/mixin/cached_convertable.py [utf8] Fri Apr 30 11:26:34 2010
@@ -87,17 +87,7 @@
http://pypi.python.org/pypi/uuid/ to generate
a uuid stored as private property.
"""
- return aq_base(self).getUid()
-
- security.declareProtected(Permissions.ModifyPortalContent, 'clearConversionCache')
- def clearConversionCache(self):
- """
- """
- if self.isTempObject():
- self.temp_conversion_data = {}
- return
- for cache_plugin in self._getCacheFactory().getCachePluginList():
- cache_plugin.delete(self._getCacheKey(), DEFAULT_CACHE_SCOPE)
+ return '%s:%s' % (aq_base(self).getUid(), self.getRevision())
security.declareProtected(Permissions.View, 'hasConversion')
def hasConversion(self, **kw):
@@ -129,7 +119,7 @@
def setConversion(self, data, mime=None, calculation_time=None, **kw):
"""
"""
- cache_id = self.generateCacheId(**kw)
+ cache_id = '%s%s' % (self._getCacheKey(), self.generateCacheId(**kw))
if self.isTempObject():
if getattr(aq_base(self), 'temp_conversion_data', None) is None:
self.temp_conversion_data = {}
@@ -139,31 +129,27 @@
cache_duration = cache_factory.cache_duration
if data is not None:
for cache_plugin in cache_factory.getCachePluginList():
- try:
- cache_entry = cache_plugin.get(self._getCacheKey(), DEFAULT_CACHE_SCOPE)
- cache_dict = cache_entry.getValue()
- except KeyError:
- cache_dict = {}
- cache_dict.update({cache_id: (self.getContentMd5(), mime, aq_base(data))})
- cache_plugin.set(self._getCacheKey(), DEFAULT_CACHE_SCOPE,
- cache_dict, calculation_time=calculation_time,
+ cache_plugin.set(cache_id, DEFAULT_CACHE_SCOPE,
+ (self.getContentMd5(), mime, aq_base(data)),
+ calculation_time=calculation_time,
cache_duration=cache_duration)
security.declareProtected(Permissions.View, 'getConversion')
def getConversion(self, **kw):
"""
"""
- cache_id = self.generateCacheId(**kw)
+ cache_id = '%s%s' % (self._getCacheKey(), self.generateCacheId(**kw))
if self.isTempObject():
return getattr(aq_base(self), 'temp_conversion_data', {})[cache_id]
for cache_plugin in self._getCacheFactory().getCachePluginList():
- cache_entry = cache_plugin.get(self._getCacheKey(), DEFAULT_CACHE_SCOPE)
- data_list = cache_entry.getValue().get(cache_id)
- if data_list:
- md5sum, mime, data = data_list
- if md5sum != self.getContentMd5():
- raise KeyError, 'Conversion cache key is compromised for %r' % cache_id
- return mime, data
+ cache_entry = cache_plugin.get(cache_id, DEFAULT_CACHE_SCOPE)
+ if cache_entry is not None:
+ data_list = cache_entry.getValue()
+ if data_list:
+ md5sum, mime, data = data_list
+ if md5sum != self.getContentMd5():
+ raise KeyError, 'Conversion cache key is compromised for %r' % cache_id
+ return mime, data
raise KeyError, 'Conversion cache key does not exists for %r' % cache_id
security.declareProtected(Permissions.View, 'getConversionSize')
More information about the Erp5-report
mailing list