[Zope3-dev] Proposal for optimized Blob handling

Christian Theune ct at gocept.com
Wed Mar 7 15:34:34 EST 2007


Am Mittwoch, den 07.03.2007, 21:31 +0100 schrieb Uwe Oestermeier:
> Christian Theune <ct at gocept.com> 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.

Christian

-- 
gocept gmbh & co. kg - forsterstraße 29 - 06112 halle/saale - germany
www.gocept.com - ct at gocept.com - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20070307/ed8bfcf1/attachment.bin


More information about the Zope3-dev mailing list