如何使用 ploneformgen 显示以提交形式上传的图像?

how to display image uploaded in a submitted form with ploneformgen?

我正在使用 ploneformgen。 [已编辑] 我正在使用来自 ploneformgen 的 自定义脚本适配器 来使用提交表单中的信息创建页面。问题是:我提交时生成的页面不显示图像。我想创建一个包含文本和一张图片的 page/document。我该怎么做?

我试过这个代码:

#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' 然后它只显示图像。

我的代码应该修改什么才能显示文本和图片?

提前致谢。

在标准的 Plone 文档内容类型上不拥有任何图像字段。

如果您在 Plone 4 上使用旧的 ATContentTypes,您必须安装和配置 collective.contentleadimage。 在 Plone 5 上,或者如果您使用的是基于 Dexterity 的内容,则必须将新的图像字段添加到您的架构中。

唯一对我有用的是我没有创建 'pages',而是将其切换为 'news items'。