[Zope3-dev] Proposal for optimized Blob handling

Uwe Oestermeier u.oestermeier at iwm-kmrc.de
Wed Mar 7 16:04:06 EST 2007


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

Uwe





________________________________________________________________
Dr. Uwe Oestermeier
Institut für Wissensmedien
Knowledge Media Research Center
Konrad-Adenauer-Str. 40
D-72072 Tuebingen
Germany
u.oestermeier at iwm-kmrc.de
Tel. +49 7071 979-208
Fax +49 7071 979-100





More information about the Zope3-dev mailing list