-
- # we don't know where we're going to save this stuff yet,
- # so I guess we'll write it to another tempfile. One we know the path of.
- # I'm assuming the tempfile we get from pylons is set to delete itself
- # when it closes, and has no visible path. Maybe I'm wrong?
- intermediate_file_descriptor, intermediate_path = tempfile.mkstemp()
-
- # that function gives me an integer file descriptor for some reason.
- intermediate_file = os.fdopen(intermediate_file_descriptor, "wb")
-
- sha1 = hashlib.sha1()
- while 1:
- data = temp.file.read(chunk_size)
- if not data:
- break
- sha1.update(data)
- intermediate_file.write(data)