[Zope3-checkins] CVS: ZODB4/src/zodb/tests - test_zodb.py:1.5 test_txn.py:1.4

Jeremy Hylton jeremy@zope.com
Tue, 20 May 2003 15:07:53 -0400


Update of /cvs-repository/ZODB4/src/zodb/tests
In directory cvs.zope.org:/tmp/cvs-serv19336/zodb/tests

Modified Files:
	test_zodb.py test_txn.py 
Log Message:
Refactor persistence api to use _p_changed only to mark an object as changed.

Use _p_deactivate() to turn an object into a ghost, and use the
keyword argument force=1 if you want to turn a modified object into a
ghost.  Several occurrences of the old interface have been updated.

This refactoring uncovered a number of subtle bugs in the persistence
C API.  The two chief problems were that the load function in the C
API struct did not set the state and that the functions return 0 for
error and 1 for success.  Regardless of whether these APIs are doing
the right thing, fix the code to use them correctly.

One downside of the new API is the C objects (BTrees) that override
_p_deactivate() have to deal with all the cruft for keyword
arguments.  Since BTrees only add a single line of extra code to
_p_deactivate(), it seems useful to provide a hook in the persistence
framework for this purpose.

Also:

If an object is in the changed state, don't call register() on its
data manager a second time.

Ignore state changes that result from setstate() being called.

Don't load an object's state to call __setstate__().

In BTrees check module, if an object has an oid, print that along with
its id().



=== ZODB4/src/zodb/tests/test_zodb.py 1.4 => 1.5 ===
--- ZODB4/src/zodb/tests/test_zodb.py:1.4	Tue Feb 25 13:55:04 2003
+++ ZODB4/src/zodb/tests/test_zodb.py	Tue May 20 15:07:23 2003
@@ -131,7 +131,7 @@
         self.assert_(o._p_changed)
         get_transaction().commit()
         self.assert_(not o._p_changed)
-        del o._p_changed
+        o._p_deactivate()
         self.assertEqual(o.anattr, "anattr")
 
     # need a test that loads an object with references to other


=== ZODB4/src/zodb/tests/test_txn.py 1.3 => 1.4 ===
--- ZODB4/src/zodb/tests/test_txn.py:1.3	Tue Jan 28 13:13:35 2003
+++ ZODB4/src/zodb/tests/test_txn.py	Tue May 20 15:07:23 2003
@@ -97,6 +97,9 @@
 class AllTests(TransactionTestBase, SubtransTests):
 
     def testSavepointAndRollback(self):
+        # XXX Should change savepoint() so that you restore to the state
+        # at the savepoint() not at the last txn activity before the
+        # savepoint().
         self.root["a"] = MinPO()
         rb1 = get_transaction().savepoint()
         self.root["b"] = MinPO()