Opening a ZOPE file object ?
Is it possible to open a file-object stored in a Zope folder through a python script using open(), receiving a standard file object, that can be passed to functions provided by standard modules (such as csv) ? f=open(self.index_html), does not work, because open takes only a string as argument. Is there a ZOPE function returning a standard file handler ? (Could not find one in the API docu, but this may be because I am new.) Or how to process a file stored in Zope through a python script ? (Ideally, I would like users to be able to upload files, have them processed and download them again. This seems to be possible with LocalFS, but is it possible from within ZOPE?)
Is there a ZOPE function returning a standard file handler ? (Could not find one in the API docu, but this may be because I am new.)
Not that I know of, no.
(Ideally, I would like users to be able to upload files, have them processed and download them again. This seems to be possible with LocalFS, but is it possible from within ZOPE?)
Yes, sure, but you fiddle the data directly, and not as a file. If you avsolutely need to make it behave lik a file you can put the stored data in a stringbuffer, or something like that.
Hi Harm, Harm_Kirchhoff@mail.digital.co.jp schrieb:
Is it possible to open a file-object stored in a Zope folder through a python script using open(), receiving a standard file object, that can be passed to functions provided by standard modules (such as csv) ? f=open(self.index_html), does not work, because open takes only a string as argument. Is there a ZOPE function returning a standard file handler ? (Could not find one in the API docu, but this may be because I am new.) Or how to process a file stored in Zope through a python script ? (Ideally, I would like users to be able to upload files, have them processed and download them again. This seems to be possible with LocalFS, but is it possible from within ZOPE?)
Zopes "File" object is not a true file you get via open(). It does not support most (any?) of the file-object methods you know. Its just a container to store a string. Someone could volontaire to write the appropriate layer... However, you can easyly process the data when it arrives, because this time you get a real file (StringIO or tempfile) and can use all methody you know (read, readline, readlines...) and therefore also the csv-module. You can write an object to store the processed data instead of the raw string. HTH Tino Wildenhain
participants (3)
-
Harm_Kirchhoff@mail.digital.co.jp -
Lennart Regebro -
Tino Wildenhain