[Plone-IT] RISOLTO: nome giusto per campo file

Fabrizio Rota fabrizio.rota a gmail.com
Lun 7 Dic 2009 08:46:49 UTC

Ecco la mia soluzione funzionante basata su weblion

# Dump this in a Custom Script Adapter.

# Available parameters:
#  fields  = HTTP request form fields as key value pairs
#  request = The current HTTP request.
#            Access fields by request.form["myfieldname"]
#  ploneformgen = PloneFormGen object
# Return value is not processed -- unless you
# return a dictionary with contents. That's regarded
# as an error and will stop processing of actions
# and return the user to the form. Error dictionaries
# should be of the form {'field_id':'Error message'}

# Do some setup:
upload_folder = context.circolari['allegati']

## Save the answer to the question of ID "thingy":
uploaded_file = fields['allegato_file']
# Prepend the user ID; append the right file extension:
upload_id = uploaded_file.filename

# If the file isn't already there, create it:
if upload_id not in upload_folder.objectIds():
    upload_folder.invokeFactory('File', id=upload_id)

# Dump the uploaded content into it:
file = upload_folder[upload_id]
file.setFile(uploaded_file.read(), filename=upload_id,

"Life is what happens to you while you're busy making other plans" - J.
-------------- parte successiva --------------
Un allegato HTML  stato rimosso...
URL: <http://lists.plone.org/pipermail/plone-plone-it/attachments/20091207/9564b997/attachment.html>

Maggiori informazioni sulla lista Plone-IT