[Erp5-report] r23969 - /erp5/trunk/products/ERP5OOo/OOoTemplate.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Oct 2 12:00:27 CEST 2008


Author: jm
Date: Thu Oct  2 12:00:18 2008
New Revision: 23969

URL: http://svn.erp5.org?rev=23969&view=rev
Log:
Replacement of <office:include_img> tags:
* Use accessor to get content type (default value is 'application/unknown').
* Revert r23844 because it would fail later anyway.
* Access data member directly instead of using getData because OFS images doesn't have getData.

Modified:
    erp5/trunk/products/ERP5OOo/OOoTemplate.py

Modified: erp5/trunk/products/ERP5OOo/OOoTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/OOoTemplate.py?rev=23969&r1=23968&r2=23969&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/OOoTemplate.py (original)
+++ erp5/trunk/products/ERP5OOo/OOoTemplate.py Thu Oct  2 12:00:18 2008
@@ -347,31 +347,24 @@
 
       picture = self._resolvePath(options_dict.pop('path').encode())
 
-      # "standard" filetype == Image or File , for ERP objects the
-      # manipulations are different
-      is_standard_filetype = True
-
       # If this is not a File, build a new file with this content
       if not isinstance(picture, File):
         tmp_picture = Products.ERP5Type.Document.newTempImage(self, 'tmp')
         tmp_picture.setData(picture())
         picture = tmp_picture
 
-      if getattr(aq_base(picture), 'data', None) is None \
-                  or callable(aq_base(picture).content_type):
-        is_standard_filetype = False
-
-      if is_standard_filetype:
-        picture_data = str(picture.getData())
+      picture_type = options_dict.pop('type', None)
+
+      picture_data = getattr(aq_base(picture), 'data', None)
+      if picture_data is None:
+        picture_data = picture.Base_download()
+        if picture_type is None:
+          picture_type = picture.content_type()
       else:
-        picture_data = picture.Base_download()
-
-      # fetch the content-type of the picture (generally guessed by zope)
-      picture_type = options_dict.pop('type', None)
-      if picture_type is None:
-        picture_type = picture.content_type
-        if not is_standard_filetype:
-          picture_type = picture_type()
+        # "standard" filetype case (Image or File)
+        picture_data = str(picture_data)
+        if picture_type is None:
+          picture_type = picture.getContentType()
 
       w, h, maxwidth, maxheight = getLengthInfos(options_dict,
                                   ('width', 'height', 'maxwidth', 'maxheight'))
@@ -405,8 +398,7 @@
 
       actual_idx = self.document_counter.next()
       pic_name = 'Pictures/picture%d%s' \
-                 % (actual_idx,
-                    picture_type and guess_extension(picture_type) or '')
+                 % (actual_idx, guess_extension(picture_type) or '')
 
       # XXX: Pictures directory not managed (seems facultative)
       #  <manifest:file-entry manifest:media-type="" manifest:full-path="ObjBFE4F50D/Pictures/"/>




More information about the Erp5-report mailing list