This is normal behavior of Python fileish objects and has nothing to do with persistence. To rewind a file back to the beginning, use the seek method: file.seek(0) AFAICT FileUpload objects should support seek. hth, Casey On Friday 05 July 2002 10:07 am, Milos Prudek wrote:
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