[Zope] Re: file upload formular
Derrick 'dman' Hudson
Wed, 12 Jun 2002 12:24:02 -0500
Content-Type: text/plain; charset=us-ascii
On Wed, Jun 12, 2002 at 04:30:12PM +0200, Simon Brun wrote:
| hi all
| For our intranet I'm going to improve the file upload. In the past, the
| workers had to upload their files via the ZMI. They had to add some prope=
| (like author, keyword, etc.). Afterwards some dtml-methods listed the con=
| the directories by mapping the properties of the documents.=20
| I now want to create a html-form which help the people to upload their fi=
| this form they have to insert the properties and after pressing the submit
| button, the file should be uploaded into Zope.
| I'm sure this was done by other users before, but I didn't find something=
| good ideas or code out there?
I have a page that allows a file upload which is passed to a script.
The page is ZPT and looks like :
<!-- Zope Page Template -->
<title tal:content=3D"template/title">The title</title>
tal:replace=3D"template/title">optional template title</span>
<input type=3D"file" size=3D"40" name=3D"FileData">
<input type=3D"submit" size=3D"40" name=3D"Submit">
The action is a Python Script that looks like this :
## Script (Python) "htpasswd_change.py"
Receive an uploaded 'htpasswd' file to be considered the authoritative
authentication contents for the acl_users folder.
request =3D container.REQUEST
the_file =3D request["FileData"]
the_file.readlines # just verify that the object is file-like
except KeyError :
print "Error: a file must be specified"
# Followed by the rest of the logic to parse the file and manipulate
# the acl_users folder. The "success" output is also simply printed
# and the end is a 'return printed' line.
If Microsoft would build a car...
=2E.. Occasionally your car would die on the freeway for no reason. You
would have to pull over to the side of the road, close all of the car
windows, shut it off, restart it, and reopen the windows before you
could continue. For some reason you would simply accept this.
Jabber ID : firstname.lastname@example.org
GnuPG key : http://dman.ddts.net/~dman/public_key.gpg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
-----END PGP SIGNATURE-----