[Zope-Checkins] CVS: Products/Transience - TransientObject.py:1.9.68.4.2.2

Chris McDonough chrism at plope.com
Tue Sep 14 17:35:30 EDT 2004


Update of /cvs-repository/Products/Transience
In directory cvs.zope.org:/tmp/cvs-serv5892

Modified Files:
      Tag: chrism-pre273-branch
	TransientObject.py 
Log Message:
Get rid of enclosing try: except: block in (unused) conflict resolver.


=== Products/Transience/TransientObject.py 1.9.68.4.2.1 => 1.9.68.4.2.2 ===
--- Products/Transience/TransientObject.py:1.9.68.4.2.1	Mon Sep 13 04:17:55 2004
+++ Products/Transience/TransientObject.py	Tue Sep 14 17:35:30 2004
@@ -202,62 +202,55 @@
         DEBUG and TLOG('entering TO _p_rc')
         DEBUG and TLOG('states: sv: %s, s1: %s, s2: %s' % (
             saved, state1, state2))
-        try:
-            states = [saved, state1, state2]
+        states = [saved, state1, state2]
 
-            # We can clearly resolve the conflict if one state is invalid,
-            # because it's a terminal state.
-            for state in states:
-                if state.has_key('_invalid'):
-                    DEBUG and TLOG('TO _p_rc: a state was invalid')
-                    return state
-            # The only other times we can clearly resolve the conflict is if
-            # the token, the id, or the creation time don't differ between
-            # the three states, so we check that here.  If any differ, we punt
-            # by raising ConflictError.
-            attrs = ['token', 'id', '_created']
-            for attr in attrs:
-                svattr = saved.get(attr)
-                s1attr = state1.get(attr)
-                s2attr = state2.get(attr)
-                DEBUG and TLOG('TO _p_rc: attr %s: sv: %s s1: %s s2: %s' %
-                               (attr, svattr, s1attr, s2attr))
-                if not svattr==s1attr==s2attr:
-                    DEBUG and TLOG('TO _p_rc: cant resolve conflict')
-                    raise ConflictError
+        # We can clearly resolve the conflict if one state is invalid,
+        # because it's a terminal state.
+        for state in states:
+            if state.has_key('_invalid'):
+                DEBUG and TLOG('TO _p_rc: a state was invalid')
+                return state
 
-            # Now we need to do real work.
-            #
-            # Data in our _container dictionaries might conflict.  To make
-            # things simple, we intentionally create a race condition where the
-            # state which was last modified "wins".  It would be preferable to
-            # somehow merge our _containers together, but as there's no
-            # generally acceptable way to union their states, there's not much
-            # we can do about it if we want to be able to resolve this kind of
-            # conflict.
+        # The only other times we can clearly resolve the conflict is if
+        # the token, the id, or the creation time don't differ between
+        # the three states, so we check that here.  If any differ, we punt
+        # by raising ConflictError.
+        attrs = ['token', 'id', '_created']
+        for attr in attrs:
+            svattr = saved.get(attr)
+            s1attr = state1.get(attr)
+            s2attr = state2.get(attr)
+            DEBUG and TLOG('TO _p_rc: attr %s: sv: %s s1: %s s2: %s' %
+                           (attr, svattr, s1attr, s2attr))
+            if not svattr==s1attr==s2attr:
+                DEBUG and TLOG('TO _p_rc: cant resolve conflict')
+                raise ConflictError
 
-            # We return the state which was most recently modified, if
-            # possible.
-            states.sort(lastmodified_sort)
-            if states[0].get('_last_modified'):
-                DEBUG and TLOG('TO _p_rc: returning last mod state')
-                return states[0]
+        # Now we need to do real work.
+        #
+        # Data in our _container dictionaries might conflict.  To make
+        # things simple, we intentionally create a race condition where the
+        # state which was last modified "wins".  It would be preferable to
+        # somehow merge our _containers together, but as there's no
+        # generally acceptable way to union their states, there's not much
+        # we can do about it if we want to be able to resolve this kind of
+        # conflict.
 
-            # If we can't determine which object to return on the basis
-            # of last modification time (no state has been modified), we return
-            # the object that was most recently accessed (last pulled out of
-            # our parent).  This will return an essentially arbitrary state if
-            # all last_accessed values are equal.
-            states.sort(lastaccessed_sort)
-            DEBUG and TLOG('TO _p_rc: returning last_accessed state')
+        # We return the state which was most recently modified, if
+        # possible.
+        states.sort(lastmodified_sort)
+        if states[0].get('_last_modified'):
+            DEBUG and TLOG('TO _p_rc: returning last mod state')
             return states[0]
-        except ConflictError:
-            raise
-        except:
-            LOG('Transience', INFO,
-                'Conflict resolution error in TransientObject', '',
-                sys.exc_info()
-                )
+
+        # If we can't determine which object to return on the basis
+        # of last modification time (no state has been modified), we return
+        # the object that was most recently accessed (last pulled out of
+        # our parent).  This will return an essentially arbitrary state if
+        # all last_accessed values are equal.
+        states.sort(lastaccessed_sort)
+        DEBUG and TLOG('TO _p_rc: returning last_accessed state')
+        return states[0]
 
     getName = getId # this is for SQLSession compatibility
 



More information about the Zope-Checkins mailing list