[Plone-IT] [risolto] il nome giusto dei campi

Fabrizio Rota fabrizio.rota a gmail.com
Sab 5 Dic 2009 23:15:16 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,
content_type=uploaded_file.headers['Content-Type'])


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


Maggiori informazioni sulla lista Plone-IT