[Zope3-dev] Proposal for optimized Blob handling
Sidnei da Silva
sidnei at enfoldsystems.com
Wed Mar 7 23:14:24 EST 2007
On 3/7/07, Christian Theune <ct at gocept.com> wrote:
> This is how the dance looks like to do the link():
>
> >>> 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.path.exists(d.name)
> False
> >>> os.path.exists('/tmp/asdf')
> True
> >>> open('/tmp/asdf').read()
> 'Test'
Ok, this is how it looks on Windows. :)
>>> import os
>>> import win32file
>>> f = open('test.txt', 'wb')
>>> f.write('hello world')
>>> f.close()
>>> win32file.CreateHardLink('hello.txt', 'test.txt')
>>> os.listdir(os.getcwd())
['hello.txt', 'test.txt']
>>> f = open('hello.txt', 'wb')
>>> f.write('hello there')
>>> f.close()
>>> print open('hello.txt').read()
hello there
>>> print open('test.txt').read()
hello there
>>> os.remove('test.txt')
>>> print open('hello.txt').read()
hello there
>>> print open('test.txt').read()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
IOError: [Errno 2] No such file or directory: 'test.txt'
--
Sidnei da Silva
Enfold Systems http://enfoldsystems.com
Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214
More information about the Zope3-dev
mailing list