[Zope] manage_addFile method

Asad Habib ahabib at engin.umich.edu
Thu Nov 4 15:07:06 EST 2004

Hello. Is there a way to pass a variable for the id argument to
manage_addFile? I want the user to be able to choose the id for a file
that they wish to upload instead of hard-coding it in as a string literal.

I have tried the following code which is inside a Python script:

fileName = REQUEST.form['publicationsFile']
context.manage_addFile(id=fileName, file=fileName, title=' ', precondition=' ', content_type='application/pdf')

The error I get is as follows:

Error Type: Bad Request
Error Value: The id "<ZPublisher.HTTPRequest.FileUpload instance at 0x46a0170>" contains characters illegal in URLs.

However, if I use a string literal, everything works fine. The following
yields no errors but doesn't serve my purpose:

fileName = REQUEST.form['publicationsFile']
context.manage_addFile(id='fileName', file=fileName, title=' ', precondition=' ', content_type='application/pdf')

Also, if anyone knows of another method that could achieve the same
purpose, please let me know. Any help would be greatly appreciated.

- Asad

More information about the Zope mailing list