[Zodb-checkins] SVN: ZODB/trunk/src/ Bug fixed:

Jim Fulton jim at zope.com
Thu Sep 16 17:23:27 EDT 2010


Log message for revision 116469:
  Bug fixed:
    Setting _p_changed on a blob wo actually writing anything caused an
    error. (https://bugs.launchpad.net/zodb/+bug/440234)
  

Changed:
  U   ZODB/trunk/src/CHANGES.txt
  U   ZODB/trunk/src/ZODB/Connection.py
  U   ZODB/trunk/src/ZODB/tests/testblob.py

-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt	2010-09-16 20:19:20 UTC (rev 116468)
+++ ZODB/trunk/src/CHANGES.txt	2010-09-16 21:23:27 UTC (rev 116469)
@@ -25,6 +25,10 @@
   there aren't any transactions.  Now a string of 8 nulls (aka "z64")
   is specified.
 
+- Setting _p_changed on a blob wo actually writing anything caused an
+  error. (https://bugs.launchpad.net/zodb/+bug/440234)
+
+
 3.10.0b6 (2010-09-08)
 =====================
 

Modified: ZODB/trunk/src/ZODB/Connection.py
===================================================================
--- ZODB/trunk/src/ZODB/Connection.py	2010-09-16 20:19:20 UTC (rev 116468)
+++ ZODB/trunk/src/ZODB/Connection.py	2010-09-16 21:23:27 UTC (rev 116469)
@@ -648,6 +648,7 @@
                     and not hasattr(obj, '_p_resolveConflict')):
                     raise ConflictError(object=obj)
                 self._modified.append(oid)
+
             p = writer.serialize(obj)  # This calls __getstate__ of obj
             if len(p) >= self.large_record_size:
                 warnings.warn(large_object_message % (obj.__class__, len(p)))
@@ -659,8 +660,12 @@
                         repr(self._storage))
                 if obj.opened():
                     raise ValueError("Can't commit with opened blobs.")
-                s = self._storage.storeBlob(oid, serial, p,
-                                            obj._uncommitted(),
+                blobfilename = obj._uncommitted()
+                if blobfilename is None:
+                    assert serial is not None # See _uncommitted
+                    self._modified.pop() # not modified
+                    continue
+                s = self._storage.storeBlob(oid, serial, p, blobfilename,
                                             '', transaction)
                 # we invalidate the object here in order to ensure
                 # that that the next attribute access of its name

Modified: ZODB/trunk/src/ZODB/tests/testblob.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testblob.py	2010-09-16 20:19:20 UTC (rev 116468)
+++ ZODB/trunk/src/ZODB/tests/testblob.py	2010-09-16 21:23:27 UTC (rev 116469)
@@ -626,7 +626,21 @@
 
     >>> db.close()
     """
+def lp440234_Setting__p_changed_of_a_Blob_w_no_uncomitted_changes_is_noop():
+    r"""
+    >>> conn = ZODB.connection('data.fs', blob_dir='blobs')
+    >>> blob = ZODB.blob.Blob('blah')
+    >>> conn.add(blob)
+    >>> transaction.commit()
+    >>> old_serial = blob._p_serial
+    >>> blob._p_changed = True
+    >>> transaction.commit()
+    >>> blob.open().read()
+    'blah'
+    >>> old_serial == blob._p_serial
+    True
 
+    """
 
 def setUp(test):
     ZODB.tests.util.setUp(test)



More information about the Zodb-checkins mailing list