[mod_python] moving file handle

Brian Ray bray at sent.com
Fri Oct 8 12:33:00 EDT 2004


This may be too simple or OT for this list, but I need some help.

I am using a custom handler and util.FieldStorage to get a file from a 
POST:

	form  = util.FieldStorage(req)

	# key datafile sent from html name
	file = form['datafile']

	# filehand is a file instance
	filehand = file['file']
	
type of filehand:

<open file '<fdopen>', mode 'w+b' at 0x1221920>

How do I save this instance file data to somewhere on disk without 
writing the file to a string? I simply want to move the file to a disk 
file where I can later access. I saw in an earlier post from David 
Fraser:

         contents = field.value
         # or you can do the read yourself:
         field.file.seek(0)
         contents = field.file.read()
         # reset the position so others can read it
         field.file.seek(0)

I understand this and it works. However, would I not get better 
performance by simply moving the temp file created from the util 
instance.

My concern is performance with larger files.

TIA, Brian



More information about the Mod_python mailing list