[Erp5-report] r40555 nicolas - /erp5/trunk/products/ERP5OOo/OOoUtils.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Nov 23 18:02:14 CET 2010
Author: nicolas
Date: Tue Nov 23 18:02:14 2010
New Revision: 40555
URL: http://svn.erp5.org?rev=40555&view=rev
Log:
When adding image inside ODF archive update also manifest file, otherwise
document is considered broken by recent OOo versions.
addImage accept new argument content_type which must be required.
But backward compatibility is kept so FutureWarning is raised instead
to inform user to update the argument list.
Modified:
erp5/trunk/products/ERP5OOo/OOoUtils.py
Modified: erp5/trunk/products/ERP5OOo/OOoUtils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/OOoUtils.py?rev=40555&r1=40554&r2=40555&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/OOoUtils.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/OOoUtils.py [utf8] Tue Nov 23 18:02:14 2010
@@ -52,6 +52,7 @@ from OFS.Image import Pdata
from lxml import etree
from lxml.etree import Element, XMLSyntaxError
from copy import deepcopy
+from warnings import warn
class CorruptedOOoFile(Exception): pass
@@ -188,13 +189,18 @@ class OOoBuilder(Implicit):
self.replace(MANIFEST_FILENAME, meta_infos)
self._manifest_additions_list = []
- def addImage(self, image, format='png'):
+ def addImage(self, image, format='png', content_type=None):
"""
Add an image to the current document and return its id
"""
count = self._image_count
self._image_count += 1
name = "Pictures/%s.%s" % (count, format)
+ if not content_type:
+ import mimetypes
+ warn('content_type argument must be passed explicitely', FutureWarning)
+ content_type = mimetypes.guess_type(name)[0]
+ self.addManifest(name, content_type)
self.replace(name, image)
is_legacy = ('oasis.opendocument' not in self.getMimeType())
return "%s%s" % (is_legacy and '#' or '', name,)
More information about the Erp5-report
mailing list