From 3549a0c5e55dbd0180a90f7229448265f7b1913c Mon Sep 17 00:00:00 2001 From: Nicolas Delaby <nicolas@nexedi.com> Date: Mon, 3 May 2010 10:06:09 +0000 Subject: [PATCH] Add temporary patch to enable updateContentMd5 calls on TextDocument git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34927 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/TextDocument.py | 17 +++++++++++++++++ product/ERP5/mixin/cached_convertable.py | 2 ++ 2 files changed, 19 insertions(+) diff --git a/product/ERP5/Document/TextDocument.py b/product/ERP5/Document/TextDocument.py index 67a0b0aedd..56fad6da24 100644 --- a/product/ERP5/Document/TextDocument.py +++ b/product/ERP5/Document/TextDocument.py @@ -37,6 +37,7 @@ from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5.Document.Document import Document, ConversionError from Products.ERP5Type.WebDAVSupport import TextContent import re +import md5 try: from string import Template @@ -295,3 +296,19 @@ class TextDocument(Document, TextContent): def getMimeTypeAndContent(self): """This method returns a tuple which contains mimetype and content.""" return (self.getTextFormat(), self.getTextContent()) + + security.declareProtected(Permissions.ModifyPortalContent, 'updateContentMd5') + def updateContentMd5(self): + """Update md5 checksum from the original file + + XXX-JPS - this method is not part of any interfacce. + should it be public or private. It is called + by some interaction workflow already. Is + it general or related to caching only ? + """ + data = self.getTextContent() + if data is not None: + data = str(data) # Usefull for Pdata + self._setContentMd5(md5.new(data).hexdigest()) # Reindex is useless + else: + self._setContentMd5(None) diff --git a/product/ERP5/mixin/cached_convertable.py b/product/ERP5/mixin/cached_convertable.py index 0c2a0f7599..cd6923adcb 100644 --- a/product/ERP5/mixin/cached_convertable.py +++ b/product/ERP5/mixin/cached_convertable.py @@ -181,3 +181,5 @@ class CachedConvertableMixin: if data is not None: data = str(data) # Usefull for Pdata self._setContentMd5(md5.new(data).hexdigest()) # Reindex is useless + else: + self._setContentMd5(None) -- 2.30.9