[Zope3-checkins] CVS: Zope3/src/persistence/tests - test_persistence.py:1.11

Jeremy Hylton jeremy@zope.com
Mon, 30 Jun 2003 11:52:49 -0400


Update of /cvs-repository/Zope3/src/persistence/tests
In directory cvs.zope.org:/tmp/cvs-serv13557/persistence/tests

Modified Files:
	test_persistence.py 
Log Message:
Fix for setting _p_changed on a ghost: Ignore it.

This is a weird corner case.  The old behavior was definitely wrong --
mark object as changed but do not register with data manager.  The new
behavior is to ignore the assignment, but it might be better to raise
an exception.


=== Zope3/src/persistence/tests/test_persistence.py 1.10 => 1.11 ===
--- Zope3/src/persistence/tests/test_persistence.py:1.10	Tue May 20 15:01:38 2003
+++ Zope3/src/persistence/tests/test_persistence.py	Mon Jun 30 11:52:48 2003
@@ -107,6 +107,18 @@
         p._p_changed = 1
         self.assertEqual(dm.called, 1)
 
+    def testGhostChanged(self):
+        # An object is a ghost, and it's _p_changed it set to True.
+        # This assignment should have no effect.
+        p = self.klass()
+        p._p_oid = 1
+        dm = DM()
+        p._p_jar = dm
+        p._p_deactivate()
+        self.assertEqual(p._p_state, 3)
+        p._p_changed = True
+        self.assertEqual(p._p_state, 3)
+
     def testRegistrationFailure(self):
         p = self.klass()
         p._p_oid = 1
@@ -131,7 +143,7 @@
         p._p_deactivate()  # make it a ghost
         
         try:
-            p._p_changed = 0    # request unghostification
+            p._p_activate()
         except NotImplementedError:
             pass
         else: