[Zope] namespaces and uploading files etc

Allen Wallis allen@rrsg.ee.uct.ac.za
Thu, 30 Mar 2000 18:24:25 +0200


Hi,
I've written an external method that will write some data to a specified
location in the server's file system. I would like a user to be able to
upload a binary file, and for the external method to then write that
file to the local file system. I understand that when a user uploads
something using an <INPUT TYPE="file" NAME="uFile"> that the file is
encapsulated in a FileUpload object. That data would be accessible in my
external method using REQUEST.uFile.read().
However, suppose my external method is defined as :
def writeFile(self, file, rootdir, filename):
    ...write data using f.write(file.read())
    return filename

I would like the argument "file" above to be a reference to
REQUEST.uFile. Also, the "filename" that is returned would be the actual
filename used (it may have been altered due to filename clashes or
whatever).
I tried using the following dtml to call this method:
<dtml-let filename="writeFileLocally(_.None, _, _.uFile,
  '/usr/local/ZopeExternalFiles/Components', _.uFile.filename)">
<dtml-var filename>
</dtml-let>
However zope complains...
I'm obviously still fumbling with zope's namespaces.

Thanks
Allen