Commit 587d8392 authored by Jérome Perrin's avatar Jérome Perrin

If the image we are trying to use in office:include_img is not an Image, call

it and generate a temp image with the content. This works for methods returning
image content directly.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19845 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 18f55fae
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
from types import StringType from types import StringType
from zLOG import LOG from zLOG import LOG
from zLOG import PROBLEM from zLOG import PROBLEM
from OFS.Image import File
from Products.CMFCore.FSPageTemplate import FSPageTemplate from Products.CMFCore.FSPageTemplate import FSPageTemplate
from Products.CMFCore.DirectoryView import registerFileExtension, registerMetaType from Products.CMFCore.DirectoryView import registerFileExtension, registerMetaType
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
...@@ -38,6 +39,7 @@ from Products.ERP5Type import PropertySheet ...@@ -38,6 +39,7 @@ from Products.ERP5Type import PropertySheet
from urllib import quote from urllib import quote
from Globals import InitializeClass, DTMLFile, get_request from Globals import InitializeClass, DTMLFile, get_request
from Globals import DevelopmentMode from Globals import DevelopmentMode
from Acquisition import aq_base
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from OOoUtils import OOoBuilder from OOoUtils import OOoBuilder
from zipfile import ZipFile, ZIP_DEFLATED from zipfile import ZipFile, ZIP_DEFLATED
...@@ -56,6 +58,7 @@ except ImportError: ...@@ -56,6 +58,7 @@ except ImportError:
SUPPORTS_WEBDAV_LOCKS = 0 SUPPORTS_WEBDAV_LOCKS = 0
from Products.ERP5.Document.Document import ConversionError from Products.ERP5.Document.Document import ConversionError
import Products.ERP5Type.Document
# Constructors # Constructors
manage_addOOoTemplate = DTMLFile("dtml/OOoTemplate_add", globals()) manage_addOOoTemplate = DTMLFile("dtml/OOoTemplate_add", globals())
...@@ -344,8 +347,15 @@ xmlns:config="http://openoffice.org/2001/config" office:version="1.0"> ...@@ -344,8 +347,15 @@ xmlns:config="http://openoffice.org/2001/config" office:version="1.0">
# manipulations are different # manipulations are different
is_standard_filetype = True is_standard_filetype = True
if getattr(picture, 'data', None) is None \ # If this is not a File, build a new file with this content
or callable(picture.content_type): 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 is_standard_filetype = False
if is_standard_filetype: if is_standard_filetype:
......
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