[Zope3-dev] Proposal for optimized Blob handling

Christian Theune ct at gocept.com
Wed Mar 7 16:09:33 EST 2007


Am Mittwoch, den 07.03.2007, 22:04 +0100 schrieb Uwe Oestermeier:
> Christian Theune <ct at gocept.com> schreibt:
> >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.
> 
> Ok, but what Dieter means is that the tmp dir as a whole is emptied from
> time to time.


> I see your point that closing a temp file removes it whereas the link
> still works,
> but that does not solve the problem that system administrators may sweep
> things out.

It does because we do need tmp partition to be the same as the blob
partition. 

> The following solution avoids this problem:
> 
> >>> os.mkdir('/Users/uo/blobs')
> >>> d = tempfile.NamedTemporaryFile()
> >>> d.write('Test')
> >>> d.flush()
> >>> os.rename(d.name, '/Users/uo/blobs/asdf')
> >>> open('/Users/uo/blobs/asdf').read()
> 'Test'
> >>> os.path.exists('/tmp/asdf')
> False

This won't work because if it's not the same partition (which you imply
is needed because the tmp-partition might be cleared out by admins) then
rename isn't available.

This also doesn't work on windows as an opened file can not be renamed
on windows.

Again, another pointer to move this dicussion to zodb-dev.

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/ebcc7c5f/attachment.bin


More information about the Zope3-dev mailing list