Commit bd91e42a authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

add asRawText() in mixin.text_convertable that does no substitution.

it should be used to get SearchableText that should be static.
parent 8df1f143
......@@ -128,7 +128,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin,
**substitution_method_parameter_dict)
def _convert(self, format, substitution_method_parameter_dict=None,
safe_substitute=True, charset=None, text_content=None, **kw):
safe_substitute=True, charset=None, text_content=None, substitute=True, **kw):
"""
Convert text using portal_transforms or oood
"""
......@@ -184,7 +184,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin,
self.setConversion(result, original_mime_type, **kw)
else:
mime_type, result = self.getConversion(**kw)
if format in VALID_TEXT_FORMAT_LIST:
if substitute and format in VALID_TEXT_FORMAT_LIST:
# only textual content can be sustituted
if substitution_method_parameter_dict is None:
substitution_method_parameter_dict = {}
......
......@@ -49,6 +49,16 @@ class TextConvertableMixin:
mime, data = self.convert(format='txt', **kw)
return str(data)
security.declareProtected(Permissions.AccessContentsInformation,
'asRawText')
def asRawText(self, **kw):
"""
Converts the current document to plain text without substitution
"""
kw.pop('format', None)
mime, data = self.convert(format='txt', substitute=False, **kw)
return str(data)
security.declareProtected(Permissions.AccessContentsInformation,
'asTextContent')
def asTextContent(self, **kw):
......
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