Commit 1e482db2 authored by Nicolas Delaby's avatar Nicolas Delaby

* rename _convert into _getConversionFromProxyServer

* then rename convert into _convert
This insure that all convert method use the same implementation
and improve consistency between all types of documents.

see Products.ERP5.mixin.document.convert



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35996 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 31fe330f
...@@ -262,7 +262,7 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File, ...@@ -262,7 +262,7 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File,
""" """
return format in self.getTargetFormatList() return format in self.getTargetFormatList()
def _convert(self, format): def _getConversionFromProxyServer(self, format):
""" """
Communicates with server to convert a file Communicates with server to convert a file
""" """
...@@ -297,14 +297,12 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File, ...@@ -297,14 +297,12 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File,
return response_dict['mime'], Pdata(dec(response_dict['data'])) return response_dict['mime'], Pdata(dec(response_dict['data']))
# Conversion API # Conversion API
security.declareProtected(Permissions.AccessContentsInformation, 'convert') def _convert(self, format, display=None, **kw):
def convert(self, format, display=None, **kw):
"""Convert the document to the given format. """Convert the document to the given format.
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():
...@@ -351,7 +349,7 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File, ...@@ -351,7 +349,7 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File,
#Text conversion is not supported by oood, do it in other way #Text conversion is not supported by oood, do it in other way
if not self.hasConversion(format=original_format): if not self.hasConversion(format=original_format):
#Do real conversion for text #Do real conversion for text
mime, data = self._convert(format='text-content') mime, data = self._getConversionFromProxyServer(format='text-content')
self.setConversion(data, mime, format=original_format) self.setConversion(data, mime, format=original_format)
return mime, data return mime, data
return self.getConversion(format=original_format) return self.getConversion(format=original_format)
...@@ -373,7 +371,7 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File, ...@@ -373,7 +371,7 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File,
has_format = self.hasConversion(format=original_format, display=display) has_format = self.hasConversion(format=original_format, display=display)
if not has_format: if not has_format:
# Do real conversion # Do real conversion
mime, data = self._convert(format) mime, data = self._getConversionFromProxyServer(format)
if is_html: if is_html:
# Extra processing required since # Extra processing required since
# we receive a zip file # we receive a zip file
...@@ -440,7 +438,7 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File, ...@@ -440,7 +438,7 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File,
format_list = [x for x in self.getTargetFormatList() format_list = [x for x in self.getTargetFormatList()
if x.startswith('html') or x.endswith('html')] if x.startswith('html') or x.endswith('html')]
format = format_list[0] format = format_list[0]
mime, data = self._convert(format) mime, data = self._getConversionFromProxyServer(format)
archive_file = cStringIO.StringIO() archive_file = cStringIO.StringIO()
archive_file.write(str(data)) archive_file.write(str(data))
zip_file = zipfile.ZipFile(archive_file) zip_file = zipfile.ZipFile(archive_file)
......
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