[Zope] Opening a ZOPE file object ?

Tino Wildenhain tino at wildenhain.de
Fri Dec 5 03:36:05 EST 2003


Hi Harm,

Harm_Kirchhoff at 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





More information about the Zope mailing list