[Zope3-checkins] SVN: Zope3/trunk/src/zope/ Changed endInteraction not to throw when there is no active interaction.

Marius Gedminas marius at pov.lt
Fri May 14 09:17:38 EDT 2004


Log message for revision 24646:
Changed endInteraction not to throw when there is no active interaction.




-=-
Modified: Zope3/trunk/src/zope/app/publication/zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/zopepublication.py	2004-05-14 11:53:49 UTC (rev 24645)
+++ Zope3/trunk/src/zope/app/publication/zopepublication.py	2004-05-14 13:17:37 UTC (rev 24646)
@@ -152,8 +152,7 @@
         self.annotateTransaction(txn, request, ob)
 
         # Make sure the interaction is ended
-        try: endInteraction()
-        except: pass # XXX I do not like this except clause, but it makes tests pass
+        endInteraction()
 
         txn.commit()
 
@@ -231,8 +230,7 @@
         get_transaction().abort()
 
         # Make sure the interaction is ended
-        try: endInteraction()
-        except: pass
+        endInteraction()
 
         # Convert ConflictErrors to Retry exceptions.
         if retry_allowed and isinstance(exc_info[1], ConflictError):

Modified: Zope3/trunk/src/zope/app/tests/functional.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/functional.py	2004-05-14 11:53:49 UTC (rev 24645)
+++ Zope3/trunk/src/zope/app/tests/functional.py	2004-05-14 13:17:37 UTC (rev 24646)
@@ -265,8 +265,7 @@
                 if request:
                     request.close()
                 # Make sure the interaction is ended
-                try: endInteraction()
-                except: pass
+                endInteraction()
         if errors:
             self.fail("%s contains broken links:\n" % path
                       + "\n".join(["  %s:\t%s" % (a, e) for a, e in errors]))

Modified: Zope3/trunk/src/zope/security/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/security/interfaces.py	2004-05-14 11:53:49 UTC (rev 24645)
+++ Zope3/trunk/src/zope/security/interfaces.py	2004-05-14 13:17:37 UTC (rev 24646)
@@ -153,12 +153,17 @@
 
 
 class IInteractionManagement(Interface):
-    """Interaction management API."""
+    """Interaction management API.
 
+    Every thread has at most one active interaction at a time.
+    """
+
     def newInteraction(participation=None):
         """Start a new interaction.
 
         If participation is not None, it is added to the new interaction.
+
+        Raises an error if the calling thread already has an interaction.
         """
 
     def getInteraction():
@@ -169,5 +174,8 @@
         """
 
     def endInteraction():
-        """End the current interaction."""
+        """End the current interaction.
 
+        Does nothing if there is no interaction.
+        """
+

Modified: Zope3/trunk/src/zope/security/management.py
===================================================================
--- Zope3/trunk/src/zope/security/management.py	2004-05-14 11:53:49 UTC (rev 24645)
+++ Zope3/trunk/src/zope/security/management.py	2004-05-14 13:17:37 UTC (rev 24646)
@@ -80,9 +80,6 @@
 
 def endInteraction(_thread=None):
     """End the current interaction."""
-    if getInteraction(_thread=_thread) is None:
-        raise AssertionError("endInteraction called"
-                             " without an active interaction")
     thread_globals(_thread).interaction = None
 
 

Modified: Zope3/trunk/src/zope/security/tests/test_management.py
===================================================================
--- Zope3/trunk/src/zope/security/tests/test_management.py	2004-05-14 11:53:49 UTC (rev 24645)
+++ Zope3/trunk/src/zope/security/tests/test_management.py	2004-05-14 13:17:37 UTC (rev 24646)
@@ -83,7 +83,9 @@
         endInteraction(_thread=thread)
         self.assert_(thread.__zope3_thread_globals__.interaction is None)
 
-        self.assertRaises(AssertionError, endInteraction, _thread=thread)
+        # again
+        endInteraction(_thread=thread)
+        self.assert_(thread.__zope3_thread_globals__.interaction is None)
 
     def test_checkPermission(self):
         from zope.security import checkPermission




More information about the Zope3-Checkins mailing list