[Zope] python script to upload file with dynamically generated
filename
Edward Muller
edwardam@interlix.com
28 Jul 2003 18:09:37 -0500
--=-xmyRRln/PTS4VOAIB5aW
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
filename =3D 'thefile'
extension =3D '.jpg'
manage_addFile(id=3D'%s%s % (filename, extension)', title=3D'', file=3Dfile=
)
On Mon, 2003-07-28 at 17:56, David Siedband wrote:
> I'm working on a script to upload a file to a file repository (zope=20
> folder) and generate a custom file name. My intention is to use a=20
> LocalFS object (instead of the Zope folder) once this bit is sorted.
>=20
> My goal is to rename the file based on the filename and extension=20
> variables that I'm passing to the script.
>=20
> The part I'm stuck on is the syntax of this part:
> manage_addFile(id=3D'%s%s % (filename, extension)', title=3D'', file=3Dfi=
le)
>=20
> In this example I'd like to set the id to 'thefile.jpg'
>=20
> TIA,
>=20
> David
>=20
> +++++++++++++ [ script ] +++++++++++++++
>=20
>=20
> #parameters file, filename=3D'thefile', extension=3D'.jpg'
>=20
> """
> Uploads a file to the repository with a crafted id.
> """
> from Products.PythonScripts.standard import url_quote
>=20
> # crafts the filename and creates the file
> container.Files.manage_addProduct['OFSP'].manage_addFile(id=3D'%s%s %=20
> (filename, extension)', title=3D'', file=3Dfile)
>=20
> # creates the success message
> message=3D"The file '%s' has been added to the repository." % file.filena=
me
>=20
> # redirects to the file repository interface page
> return context.REQUEST.RESPONSE.redirect("%s/repository_html?message=3D%s=
"=20
> % (container.absolute_url(), url_quote(message)))
>=20
>=20
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -=20
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
--=20
Edward Muller
Interlix (http://www.interlix.com)
Phone: 417-862-0573 - Cell: 417-844-2435 - Fax: 417-862-0572
Web Hosting - PC Service & Support - Custom Programming - Network Service &=
Support
Specializing in Open Source Solutions
--=-xmyRRln/PTS4VOAIB5aW
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQA/Ja0w9mQI3ghpenkRAtcfAJ95SjNM2RMd08g07QoAxRPJCjIyugCfSAd2
pwXnDUtiGeN3UxQ7vZH5rbQ=
=KvVl
-----END PGP SIGNATURE-----
--=-xmyRRln/PTS4VOAIB5aW--