Hi Mark,

Mark Hammond-3 wrote:
> [...]
>> unless we use some non-portable win32 code to allow writing and 
>> reading to the same file simultaneously.
> I'm not sure exactly what you mean by "simultaneously", but assuming you
> just need the ability to read and write to a file, you already can.  Does
> this behaviour help?
>>>> import tempfile
>>>> f = tempfile.NamedTemporaryFile()
>>>> f.write("hello")
>>>> f.seek(0,0)
>>>> f.read()
> 'hello'
> I can easily see it might not - as soon as the file is closed you have
> (obviously) lost it.

I should've been clearer, I meant reading and writing at the same time from
2 different file handles. 

NamedTemporaryFile has the added complication of removing the file from
under 'blob' when it's closed, so even if I don't try to open the blob after
consuming the file, the file disappears after the request is gone, and the
transaction subsequently fails when trying to rename the consumed file to
it's final location.

I also tried win32file.CreateHardLink() but if a file is open by one
hard-link, renaming the other hard-link fails, so we're stuck with copying
files wholesale on Windows, or closing the FileUpload object and letting
subsequent uses of it fail.
View this message in context: 
Sent from the Zope - Dev mailing list archive at Nabble.com.

Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to