[Zodb-checkins] SVN: ZODB/branches/zagy-lp509801/src/ZODB/ Make test a little bit easier to read.
Christian Theune
ct at gocept.com
Wed Jun 16 07:23:09 EDT 2010
Log message for revision 113519:
Make test a little bit easier to read.
The call to invalidate seems to be a bit hackish and ignores that fact that
with ZEO store() may return None. It seems that the call to invalidate simply
wants to queue the invalidation message and leverage the locking but doesn't
care too much about the order - it just needs to satisfy the guard. By using
the current transaction number of the Connection we can always ensure that the
guard will pass.
Changed:
U ZODB/branches/zagy-lp509801/src/ZODB/Connection.py
U ZODB/branches/zagy-lp509801/src/ZODB/tests/testblob.py
-=-
Modified: ZODB/branches/zagy-lp509801/src/ZODB/Connection.py
===================================================================
--- ZODB/branches/zagy-lp509801/src/ZODB/Connection.py 2010-06-16 10:54:22 UTC (rev 113518)
+++ ZODB/branches/zagy-lp509801/src/ZODB/Connection.py 2010-06-16 11:23:09 UTC (rev 113519)
@@ -335,7 +335,7 @@
def invalidate(self, tid, oids):
"""Notify the Connection that transaction 'tid' invalidated oids."""
if self.before is not None:
- # this is an historical connection. Invalidations are irrelevant.
+ # This is a historical connection. Invalidations are irrelevant.
return
self._inv_lock.acquire()
try:
@@ -1175,7 +1175,7 @@
# that that the next attribute access of its name
# unghostify it, which will cause its blob data
# to be reattached "cleanly"
- self.invalidate(s, {oid:True})
+ self.invalidate(self._txn_time, {oid:True})
else:
s = self._storage.store(oid, serial, data,
'', transaction)
Modified: ZODB/branches/zagy-lp509801/src/ZODB/tests/testblob.py
===================================================================
--- ZODB/branches/zagy-lp509801/src/ZODB/tests/testblob.py 2010-06-16 10:54:22 UTC (rev 113518)
+++ ZODB/branches/zagy-lp509801/src/ZODB/tests/testblob.py 2010-06-16 11:23:09 UTC (rev 113519)
@@ -569,21 +569,23 @@
>>> bs = create_storage()
>>> db = DB(bs)
- >>> conn = db.open()
- >>> conn.root.b = ZODB.blob.Blob('initial')
- >>> transaction.commit()
- >>> conn.root.b.open('w').write('1')
- >>> _ = transaction.savepoint()
- >>> tm = transaction.TransactionManager()
- >>> conn2 = db.open(transaction_manager=tm)
+ >>> tm1 = transaction.TransactionManager()
+ >>> conn1 = db.open(transaction_manager=tm1)
+ >>> conn1.root.b = ZODB.blob.Blob('initial')
+ >>> tm1.commit()
+ >>> conn1.root.b.open('w').write('1')
+ >>> _ = tm1.savepoint()
+
+ >>> tm2 = transaction.TransactionManager()
+ >>> conn2 = db.open(transaction_manager=tm2)
>>> conn2.root.b.open('w').write('2')
- >>> _ = tm.savepoint()
- >>> conn.root.b.open().read()
+ >>> _ = tm1.savepoint()
+ >>> conn1.root.b.open().read()
'1'
>>> conn2.root.b.open().read()
'2'
- >>> tm.commit()
- >>> transaction.commit() # doctest: +IGNORE_EXCEPTION_DETAIL
+ >>> tm2.commit()
+ >>> tm1.commit() # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ConflictError: database conflict error...
More information about the Zodb-checkins
mailing list