我正在使用ploneformgen。我正在使用来自ploneformgen的自定义脚本适配器使用来自提交表单的信息创建一个页面。问题是:我提交时生成的页面不显示图像。我想创建一个文本和一个图像的页面/文档。我怎样才能做到这一点?如何显示用ploneformgen提交的表单上传的图像?
我试过这段代码:
#Creating the folder in zope instance. I gave the name 'conteudo' to it.
targetdir = context.conteudo
#Here asking for the form, so we can access its contents
form = request.form
#Creating an unique ID
from DateTime import DateTime
uid= str(DateTime().millis())
# Creating a new Page (Document)
targetdir.invokeFactory('Document',id=uid, title= 'Minha Página', image= form['foto-de-perfil_file'],text='<b>Nome Completo:</b><br>'+form
['nome-completo']+'<br><br>'+'<b>Formação:</b><br>'+form
['formacao']+'<br><br>'+'<b>Áreas de Atuação:</b><br>'+form['areas-de- atuacao']+'<br><br>'+'<b>Links:</b><br>'+form['links'])
# Set the reference for our new Page
doc = targetdir.get('uid',targetdir)
# Reindexed the Page in the site
doc.reindexObject()
只显示文本,但画面不存在。
我尝试使用“setImage”,但它显示属性错误。我试着制作另一个invokefactory,但不是'Document',而是放置'Image',然后它只显示图像。
我该怎么修改我的代码来显示都的文字和图片?
在此先感谢。
我想你在这里提到了很多细节。 这个coe如何被执行?看着你的代码*看起来*你有一个用于PloneFormGen的脚本适配器,用于创建一个'Document'内容类型,并且这个文档也有一个非标准的图像字段(你使用'collective.contentleadimage'或者什么?)。 请确认这些细节,或尝试去给我们更多关于你env的信息。 –
update->编辑 –
乍一看,我认为你需要一个带有图像字段的文档。对于Plone-4,还有一个附加的'collective'contentleadimage',您可以使用它扩展任何现有的内容类型和图像字段。在Plone-5中有一种行为给你这种可能性。 –