[Zodb-checkins] SVN: ZODB/trunk/src/ZODB/ Fixed bug: if the blob directory given when creating a blob was a

Jim Fulton jim at zope.com
Mon Oct 27 17:46:48 EDT 2008


Log message for revision 92637:
  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.
  

Changed:
  U   ZODB/trunk/src/ZODB/blob.py
  U   ZODB/trunk/src/ZODB/tests/testblob.py

-=-
Modified: ZODB/trunk/src/ZODB/blob.py
===================================================================
--- ZODB/trunk/src/ZODB/blob.py	2008-10-27 21:31:35 UTC (rev 92636)
+++ ZODB/trunk/src/ZODB/blob.py	2008-10-27 21:46:48 UTC (rev 92637)
@@ -302,7 +302,7 @@
     # 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':

Modified: ZODB/trunk/src/ZODB/tests/testblob.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testblob.py	2008-10-27 21:31:35 UTC (rev 92636)
+++ ZODB/trunk/src/ZODB/tests/testblob.py	2008-10-27 21:46:48 UTC (rev 92637)
@@ -620,6 +620,24 @@
     >>> 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



More information about the Zodb-checkins mailing list