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,
content_type=uploaded_file.headers['Content-Type'])


-- 
Faber
--------------------
"Life is what happens to you while you're busy making other plans" - J.
Lennon
_______________________________________________
Plone-IT mailing list
Plone-IT@lists.plone.org
http://lists.plone.org/mailman/listinfo/plone-it
http://www.nabble.com/Plone---Italy-f21728.html

Reply via email to