[Zope] Upload, read() and a rather unexpected persistence

Milos Prudek milos.prudek@tiscali.cz
Fri, 05 Jul 2002 16:07:23 +0200


Hi,

I just found out that it is impossible to use File.read(20000) twice 
even in separate scripts, because Zope remembers the file position.

Therefore data must be saved in the same Python Script that checks for 
validity and the data distilled from File.read must be saved elsewhere, 
if the saving procedure would use File.read again.

Details:

HTTP upload files may be checked via simple routine:

fault=[]
for F in files:
    Ft = context.filetype(F.file.read(20000))
    # filetype is External method that calls UNIX's file command
    if Ft.find('GIF image data')==-1:
       fault.append('Not an image'.)

But it is impossible to use F.file.read(20000) in a second script whose 
execution follows, because Zope remembers the 20000 position and will 
start reading at position 20001.

Is this a feature (persistence), or a bug?


-- 
Milos Prudek