Commit 4bd23876 authored by Nicolas Delaby's avatar Nicolas Delaby

All convert() methods become _convert() (private one is real implemtation).

As a reminder convert() aims to check Conversion Format Permission.
remove obsolete security statements



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35749 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3176bb40
...@@ -427,6 +427,7 @@ class EmailDocument(TextDocument): ...@@ -427,6 +427,7 @@ class EmailDocument(TextDocument):
main content (text/plain). main content (text/plain).
TODO: add support for legacy objects TODO: add support for legacy objects
""" """
self._checkConversionFormatPermission(None)
if not self.hasFile() or self._baseGetTextContent() is not None: if not self.hasFile() or self._baseGetTextContent() is not None:
# Return the standard text content if no file was provided # Return the standard text content if no file was provided
# Or standard text content is not empty. # Or standard text content is not empty.
......
...@@ -323,8 +323,7 @@ class Image(TextConvertableMixin, File, OFSImage): ...@@ -323,8 +323,7 @@ class Image(TextConvertableMixin, File, OFSImage):
return mime_type, result return mime_type, result
# Conversion API # Conversion API
security.declareProtected(Permissions.AccessContentsInformation, 'convert') def _convert(self, format, **kw):
def convert(self, format, **kw):
""" """
Implementation of conversion for Image files Implementation of conversion for Image files
""" """
......
...@@ -67,8 +67,7 @@ class PDFDocument(Image): ...@@ -67,8 +67,7 @@ class PDFDocument(Image):
) )
# Conversion API # Conversion API
security.declareProtected(Permissions.AccessContentsInformation, 'convert') def _convert(self, format, **kw):
def convert(self, format, **kw):
""" """
Implementation of conversion for PDF files Implementation of conversion for PDF files
""" """
...@@ -89,7 +88,7 @@ class PDFDocument(Image): ...@@ -89,7 +88,7 @@ class PDFDocument(Image):
self.setConversion(data, mime=mime, format='txt') self.setConversion(data, mime=mime, format='txt')
return (mime, data) return (mime, data)
else: else:
return Image.convert(self, format, **kw) return Image._convert(self, format, **kw)
security.declareProtected(Permissions.ModifyPortalContent, 'populateContent') security.declareProtected(Permissions.ModifyPortalContent, 'populateContent')
def populateContent(self): def populateContent(self):
......
...@@ -131,8 +131,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, ...@@ -131,8 +131,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin,
return self._substituteTextContent(subject, safe_substitute=safe_substitute, return self._substituteTextContent(subject, safe_substitute=safe_substitute,
**substitution_method_parameter_dict) **substitution_method_parameter_dict)
security.declareProtected(Permissions.AccessContentsInformation, 'convert') def _convert(self, format, substitution_method_parameter_dict=None,
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, **kw):
""" """
Convert text using portal_transforms or oood Convert text using portal_transforms or oood
...@@ -239,6 +238,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, ...@@ -239,6 +238,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin,
def getBaseData(self, default=_MARKER): def getBaseData(self, default=_MARKER):
""" """
""" """
self._checkConversionFormatPermission(None, **kw)
if default is _MARKER: if default is _MARKER:
return self.getTextContent() return self.getTextContent()
else: else:
......
...@@ -262,7 +262,6 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File, ...@@ -262,7 +262,6 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File,
""" """
return format in self.getTargetFormatList() return format in self.getTargetFormatList()
security.declarePrivate('_convert')
def _convert(self, format): def _convert(self, format):
""" """
Communicates with server to convert a file Communicates with server to convert a file
...@@ -305,6 +304,7 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File, ...@@ -305,6 +304,7 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File,
If a conversion is already stored for this format, it is returned If a conversion is already stored for this format, it is returned
directly, otherwise the conversion is stored for the next time. directly, otherwise the conversion is stored for the next time.
""" """
self._checkConversionFormatPermission(format, **kw)
#XXX if document is empty, stop to try to convert. #XXX if document is empty, stop to try to convert.
#XXX but I don't know what is a appropriate mime-type.(Yusei) #XXX but I don't know what is a appropriate mime-type.(Yusei)
if not self.hasData(): if not self.hasData():
......
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