[Zope3-dev] Proposal for optimized Blob handling

Christian Theune ct at gocept.com
Wed Mar 7 19:12:43 EST 2007


Am Donnerstag, den 08.03.2007, 00:32 +0100 schrieb Wichert Akkerman:
> Previously Christian Theune wrote:
> > 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.
> 
> 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.

Please have a look at http://wiki.zope.org/ZODB/BlobsZeroCopy before
continuing this thread.

-- 
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/20070308/08c35ad3/attachment-0001.bin


More information about the Zope3-dev mailing list