Previously Christian Theune wrote:
> Am Mittwoch, den 07.03.2007, 21:31 +0100 schrieb Uwe Oestermeier:
> > Christian Theune <[EMAIL PROTECTED]> schreibt:
> > >
> > >Nope. It won't disappear if you link it again. And the link(src, dst)
> > >does move it to a 'save' location ;)
> > 
> > Again I'm not convinced because you cannot be sure that no other process
> > deletes the temp file.
> > In the following I simulate this with a os.system call:
> > 
> > >>> import tempfile, os
> > >>> d = tempfile.NamedTemporaryFile()
> > >>> os.path.exists(d.name)
> > True
> > >>> d.write('Test')
> > >>> os.path.exists('/tmp/asdf')
> > False
> > >>> os.link(d.name, '/tmp/asdf')
> > >>> d.close()
> > >>> os.system('rm /tmp/asdf')
> > 0
> > >>> os.path.exists('/tmp/asdf')
> > False
> > >>> open('/tmp/asdf').read()
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in ?
> > IOError: [Errno 2] No such file or directory: '/tmp/asdf'
> 
> Nope this is not the correct simulation. Who except your application
> knows about /tmp/asdf? You have to simulate deleting d.name and then
> you'll see that /tmp/asdf does not disappear.
> 
> The link operation *is* the rename except that now two files link to it.
> This keeps the semantics of a NamedTemporaryFile in respect to the
> request processing and the publisher intact.

Two possible things come to mind:
- if the tempfile is on a different filesystem you can not link the file
  elsehere. Can we guarantee that they will be on the same filesystem?
- does this work on non-posix systems such as windows?

Wichert.


-- 
Wichert Akkerman <[EMAIL PROTECTED]>    It is simple to make things.
http://www.wiggy.net/                   It is hard to make things simple.
_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to