[Setup] Create file objects in Plone Script Adapter
chris
chris at eehmke.de
Sun Mar 13 17:37:03 UTC 2011
Ken Wasetis [Contextual Corp.] wrote:
> There's a Documentation area for the PloneFormGen product, where Steve
> M. posted this nice little how-to:
> http://plone.org/products/ploneformgen/documentation/how-to/creating-
content-from-pfg
Hi Ken, thanks that howto I did find too. But it does not answer my question
about file content. I found myself a solution that is not mentioned in any
howto, here is a code snippet of my script adapter:
file_uploader = form['file_upload_file']
file_name = file_uploader.filename
if file_name:
fid = eventfolder.invokeFactory("File", id=file_name, title=file_name)
file = getattr (eventfolder, fid)
file.setFile (file_uploader)
That works fine, with with invokeFactory ("Image"...)... file.setImage for
images too. I wonder why this simple approach is never mentioned in any
guide.
More information about the Setup
mailing list