[Zope] searching and serving large textfiles ~120 Mb

Peter Sabaini peter at sabaini.at
Tue Dec 9 03:44:16 EST 2003



Sebastian Krollmann wrote:
> Hi Peter,
> 
> 
>>Hm, I think (downloading) performance should be roughly the same --
>>after all, the files would still have to loaded by Zope, at least with
>>Products like LocalFS and ExtFile that first load the whole file into
>>memory before starting to serve it? I wrote myself a streaming method
>>for this reason.
> 
> 
> So either to patch LocalFS and ExtFile not to wait until complete load or
> reading
> the file by external methods like Dieter Maurer suggested.
> 
> What does your streaming method do, just downloading the file?

Its pretty simple -- I actually use LocalFS so users can browse / upload 
files, and this:

def streamFile(file, name, REQUEST):
     """file is a LocalFS file object, name is the file name"""
     resp = REQUEST.RESPONSE
     path = file.path
     ctype = file._getType()
     size = file.get_size()
     # logging.debug("setting type: %s, path: %s" % (ctype, path))
     resp.setHeader('Content-Type', ctype)
     resp.setHeader('Content-Length', size)
     resp.setHeader('Content-Location', name)
     read = open(path, 'rb').read
     write = resp.write
     while 1:
         data = read(CONST_STREAMREADSIZE)
         if data == '': break
         write(data)

is for downloading.

hth,
peter.


> Thanks for your answers,
> 
> SK
> 
> 
> 
> 
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3461 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.zope.org/pipermail/zope/attachments/20031209/d5651a2a/smime.bin


More information about the Zope mailing list