Commit 06e77361 authored by Jim Fulton's avatar Jim Fulton

Bug fixed:

  Setting _p_changed on a blob wo actually writing anything caused an
  error. (https://bugs.launchpad.net/zodb/+bug/440234)
parent 110881a1
...@@ -25,6 +25,10 @@ Bugs fixed ...@@ -25,6 +25,10 @@ Bugs fixed
there aren't any transactions. Now a string of 8 nulls (aka "z64") there aren't any transactions. Now a string of 8 nulls (aka "z64")
is specified. 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) 3.10.0b6 (2010-09-08)
===================== =====================
......
...@@ -648,6 +648,7 @@ class Connection(ExportImport, object): ...@@ -648,6 +648,7 @@ class Connection(ExportImport, object):
and not hasattr(obj, '_p_resolveConflict')): and not hasattr(obj, '_p_resolveConflict')):
raise ConflictError(object=obj) raise ConflictError(object=obj)
self._modified.append(oid) self._modified.append(oid)
p = writer.serialize(obj) # This calls __getstate__ of obj p = writer.serialize(obj) # This calls __getstate__ of obj
if len(p) >= self.large_record_size: if len(p) >= self.large_record_size:
warnings.warn(large_object_message % (obj.__class__, len(p))) warnings.warn(large_object_message % (obj.__class__, len(p)))
...@@ -659,8 +660,12 @@ class Connection(ExportImport, object): ...@@ -659,8 +660,12 @@ class Connection(ExportImport, object):
repr(self._storage)) repr(self._storage))
if obj.opened(): if obj.opened():
raise ValueError("Can't commit with opened blobs.") raise ValueError("Can't commit with opened blobs.")
s = self._storage.storeBlob(oid, serial, p, blobfilename = obj._uncommitted()
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) '', transaction)
# we invalidate the object here in order to ensure # we invalidate the object here in order to ensure
# that that the next attribute access of its name # that that the next attribute access of its name
......
...@@ -626,7 +626,21 @@ def savepoint_cleanup(): ...@@ -626,7 +626,21 @@ def savepoint_cleanup():
>>> db.close() >>> 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): def setUp(test):
ZODB.tests.util.setUp(test) ZODB.tests.util.setUp(test)
......
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