Commit 001b5d4d authored by Nicolas Delaby's avatar Nicolas Delaby

content_md5 needs to compute its value against original value.

As TextDocument can store this original value in data property (Ingestion Input)
or text_content property (UI Input).
content_md5 is computed against getData, then TextDocument instances must fallback
on getTextContent if data is empty.
getData usage is unified among all types of documents.

Additional Comments:
TextDocument._convert() still rely on text_content value as raw_data.
because if data exists, text_content also, as a base conversion of data.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41849 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 75ce5f16
......@@ -390,3 +390,19 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin,
LOG('TextDocument', WARNING,
'Usage of text_format is deprecated, use text_content instead')
return self._setContentType(value)
def getData(self, default=_MARKER):
"""getData must returns original content but TextDocument accepts
data or text_content to store original content.
Fallback on text_content property if data is not defined
"""
if not self.hasData():
if default is _MARKER:
return self.getTextContent()
else:
return self.getTextContent(default)
else:
if default is _MARKER:
return File.getData(self)
else:
return File.getData(self, default)
......@@ -247,7 +247,7 @@ class CachedConvertableMixin:
def updateContentMd5(self):
"""Update md5 checksum from the original file
"""
mime, data = self.convert(None)
data = self.getData()
if data is not None:
if isinstance(data, Pdata):
self._setContentMd5(hashPdataObject(aq_base(data)))
......
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