Commit dafad728 authored by Jim Fulton's avatar Jim Fulton

Fixed bug: if the blob directory given when creating a blob was a

relative path, the blob machinery used relative paths, which could
lead to breakage if an application changed directories.
parent 96d11970
......@@ -302,7 +302,7 @@ class FilesystemHelper:
# want to perform blob storage differently.
def __init__(self, base_dir, layout_name='automatic'):
self.base_dir = os.path.normpath(base_dir) + os.path.sep
self.base_dir = os.path.abspath(base_dir) + os.path.sep
self.temp_dir = os.path.join(base_dir, 'tmp')
if layout_name == 'automatic':
......
......@@ -620,6 +620,24 @@ def is_blob_record():
>>> db.close()
"""
def do_not_depend_on_cwd():
"""
>>> from ZODB.MappingStorage import MappingStorage
>>> bs = ZODB.blob.BlobStorage('blobs', MappingStorage())
>>> here = os.getcwd()
>>> os.mkdir('evil')
>>> os.chdir('evil')
>>> db = DB(bs)
>>> conn = db.open()
>>> conn.root()['blob'] = ZODB.blob.Blob()
>>> conn.root()['blob'].open('w').write('data')
>>> transaction.commit()
>>> os.chdir(here)
>>> conn.root()['blob'].open().read()
'data'
"""
def setUp(test):
zope.testing.setupstack.setUpDirectory(test)
test.globs['rmtree'] = zope.testing.setupstack.rmtree
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment