[Checkins] SVN: ZODB/trunk/src/ Removed support for the _p_independent mini framework, which was

Jim Fulton jim at zope.com
Thu May 13 07:10:40 EDT 2010


Log message for revision 112271:
  Removed support for the _p_independent mini framework, which was
  made moot by the introduction of multi-version concurrency control
  several years ago.
  

Changed:
  U   ZODB/trunk/src/BTrees/Length.py
  U   ZODB/trunk/src/CHANGES.txt
  U   ZODB/trunk/src/ZODB/Connection.py
  U   ZODB/trunk/src/ZODB/tests/testZODB.py
  U   ZODB/trunk/src/persistent/interfaces.py

-=-
Modified: ZODB/trunk/src/BTrees/Length.py
===================================================================
--- ZODB/trunk/src/BTrees/Length.py	2010-05-13 11:00:40 UTC (rev 112270)
+++ ZODB/trunk/src/BTrees/Length.py	2010-05-13 11:10:40 UTC (rev 112271)
@@ -47,11 +47,6 @@
     def _p_resolveConflict(self, old, s1, s2):
         return s1 + s2 - old
 
-    def _p_independent(self):
-        # My state doesn't depend on or materially effect the state of
-        # other objects.
-        return 1
-
     def change(self, delta):
         self.value += delta
 

Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt	2010-05-13 11:00:40 UTC (rev 112270)
+++ ZODB/trunk/src/CHANGES.txt	2010-05-13 11:10:40 UTC (rev 112271)
@@ -16,6 +16,10 @@
 
 - Removed the dependency on zope.proxy.
 
+- Removed support for the _p_independent mini framework, which was
+  made moot by the introduction of multi-version concurrency control
+  several years ago.
+
 Bugs Fixed
 ----------
 

Modified: ZODB/trunk/src/ZODB/Connection.py
===================================================================
--- ZODB/trunk/src/ZODB/Connection.py	2010-05-13 11:00:40 UTC (rev 112270)
+++ ZODB/trunk/src/ZODB/Connection.py	2010-05-13 11:10:40 UTC (rev 112271)
@@ -828,17 +828,10 @@
         # load.  We can only be sure about invalidations after the
         # load.
 
-        # If an object has been invalidated, there are several cases
-        # to consider:
-        # 1. Check _p_independent()
-        # 2. Try MVCC
-        # 3. Raise ConflictError.
+        # If an object has been invalidated, among the cases to consider:
+        # - Try MVCC
+        # - Raise ConflictError.
 
-        # Does anything actually use _p_independent()?  It would simplify
-        # the code if we could drop support for it.
-        # (BTrees.Length does.)
-
-
         if self.before is not None:
             # Load data that was current before the time we have.
             before = self.before
@@ -855,9 +848,7 @@
             if self._invalidatedCache:
                 raise ReadConflictError()
 
-            if (obj._p_oid in self._invalidated and
-                    not myhasattr(obj, "_p_independent")):
-                # If the object has _p_independent(), we will handle it below.
+            if (obj._p_oid in self._invalidated):
                 self._load_before_or_conflict(obj)
                 return
 
@@ -871,13 +862,8 @@
                 self._inv_lock.release()
 
             if invalid:
-                if myhasattr(obj, "_p_independent"):
-                    # This call will raise a ReadConflictError if something
-                    # goes wrong
-                    self._handle_independent(obj)
-                else:
-                    self._load_before_or_conflict(obj)
-                    return
+                self._load_before_or_conflict(obj)
+                return
 
         self._reader.setGhostState(obj, p)
         obj._p_serial = serial
@@ -926,25 +912,6 @@
 
         return True
 
-    def _handle_independent(self, obj):
-        # Helper method for setstate() handles possibly independent objects
-        # Call _p_independent(), if it returns True, setstate() wins.
-        # Otherwise, raise a ConflictError.
-
-        if obj._p_independent():
-            self._inv_lock.acquire()
-            try:
-                try:
-                    self._invalidated.remove(obj._p_oid)
-                except KeyError:
-                    pass
-            finally:
-                self._inv_lock.release()
-        else:
-            self._conflicts[obj._p_oid] = 1
-            self._register(obj)
-            raise ReadConflictError(object=obj)
-
     def register(self, obj):
         """Register obj with the current transaction manager.
 

Modified: ZODB/trunk/src/ZODB/tests/testZODB.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testZODB.py	2010-05-13 11:00:40 UTC (rev 112270)
+++ ZODB/trunk/src/ZODB/tests/testZODB.py	2010-05-13 11:10:40 UTC (rev 112271)
@@ -30,16 +30,6 @@
 class P(Persistent):
     pass
 
-class Independent(Persistent):
-
-    def _p_independent(self):
-        return 1
-
-class DecoyIndependent(Persistent):
-
-    def _p_independent(self):
-        return 0
-
 class ZODBTests(ZODB.tests.util.TestCase):
 
     def setUp(self):
@@ -495,14 +485,6 @@
         self.obj = P()
         self.readConflict()
 
-    def checkIndependent(self):
-        self.obj = Independent()
-        self.readConflict(shouldFail=False)
-
-    def checkNotIndependent(self):
-        self.obj = DecoyIndependent()
-        self.readConflict()
-    
     def checkReadConflictIgnored(self):
         # Test that an application that catches a read conflict and
         # continues can not commit the transaction later.

Modified: ZODB/trunk/src/persistent/interfaces.py
===================================================================
--- ZODB/trunk/src/persistent/interfaces.py	2010-05-13 11:00:40 UTC (rev 112270)
+++ ZODB/trunk/src/persistent/interfaces.py	2010-05-13 11:10:40 UTC (rev 112271)
@@ -246,15 +246,6 @@
         object data to be reloaded.
         """
 
-class IPersistentNoReadConflicts(IPersistent):
-    def _p_independent():
-        """Hook for subclasses to prevent read conflict errors.
-
-        A specific persistent object type can define this method and
-        have it return true if the data manager should ignore read
-        conflicts for this object.
-        """
-
 # TODO:  document conflict resolution.
 
 class IPersistentDataManager(Interface):



More information about the checkins mailing list