[Zope-dev] FileUpload and blob on Windows

Mark Hammond mhammond at skippinet.com.au
Mon Jan 28 20:21:11 EST 2008


Hi Leo,
  I'm not familiar with the Zope side of the world at all, so this may be
completely useless...

> However, if one tries to consume a NamedTemporaryFile and then open its
> generated blob before closing the tempfile, Windows complains:
> 
> 
> 
> >>>> import ZODB.blob, tempfile
> >>>> f = tempfile.NamedTemporaryFile()
> >>>> b = ZODB.blob.Blob()
> >>>> b.consumeFile(f.name)
> >>>> b.open('r')
> > Traceback (innermost last):
> > ...
> > IOError: [Errno 13] Permission denied:
> 'c:\\buildout\\var\\tmp\\tmpsuykkc'
> >
...

> 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.

Mark




More information about the Zope-Dev mailing list