Più in dettaglio, questo è un esempio funzionante, dove proposals/files è il
folder in cui salvare i file.
A proposito, chi mi dice come compattare la funzione normalizeString in
Python, senza usare regular expressions o le API di Plone?
Giovanni
# 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'}
# assert False, "Please complete your script"
def normalizeString(text, context=None):
text = text.replace(' ', '_')
text = text.replace('-', '_')
text = text.replace("'", '_')
text = text.replace('"', '_')
text = text.replace(':', '_')
return text
nome = request.form.get('nome', '')
cognome = request.form.get('cognome', '')
description = 'File caricato da %s %s.' % (nome, cognome)
file = request.form.get('draft_file', '')
if not file:
return
filename = file.filename
if filename.count('/'):
filename = filename.split('/')[-1]
if filename.count('\\'):
filename = filename.split('\\')[-1]
normalized_filename = normalizeString(filename, context=context)
replyto = request.form.get('replyto', '')
replyname = replyto.split('@')[0]
file_id = '%s_%s' % (replyname, normalized_filename)
portal = context.portal_url.getPortalObject()
proposals = getattr(portal, 'proposals')
file_folder = getattr(proposals, 'files')
file_folder.invokeFactory(type_name='File', id=file_id, title=filename,
description=description, file=file)
fileobject = getattr(file_folder, file_id)
fileobject.reindexObject()
----- Original Message -----
From: "Fabrizio Reale" <fabrizio.re...@redomino.com>
To: <plone-it@lists.plone.org>
Sent: Monday, November 16, 2009 12:20 PM
Subject: Re: [Plone-IT] Modulo di contatto "lavora con noi": qual'è la
migliore soluzione?
In data lunedì 16 novembre 2009 12:07:52, Vito Falco ha scritto:
Volendo usare PloneFormGen e il campo file, dove viene salvato il tutto?
Dove vuoi tu.
Ti crei uno script che riceve i dati inviati dal form e decidi cosa farne.
Fabry
--
Fabrizio Reale
Redomino S.r.l.
Largo Valgioie 14,
10146 Torino Italy
Tel: +39 0117499875
http://redomino.com
--------------------------------------------------------------------------------
_______________________________________________
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
_______________________________________________
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