我正在使用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中有一種行爲給你這種可能性。 –