[Zope3-checkins] SVN: Zope3/trunk/src/zope/ Renamed getInteraction to queryInteraction.

Marius Gedminas marius at pov.lt
Fri May 14 09:45:49 EDT 2004


Log message for revision 24649:
Renamed getInteraction to queryInteraction.




-=-
Modified: Zope3/trunk/src/zope/app/dublincore/creatorannotator.py
===================================================================
--- Zope3/trunk/src/zope/app/dublincore/creatorannotator.py	2004-05-14 13:41:59 UTC (rev 24648)
+++ Zope3/trunk/src/zope/app/dublincore/creatorannotator.py	2004-05-14 13:45:49 UTC (rev 24649)
@@ -17,7 +17,7 @@
 """
 from zope.app.dublincore.interfaces import IZopeDublinCore
 from zope.app.event.interfaces import ISubscriber
-from zope.security.management import getInteraction
+from zope.security.management import queryInteraction
 from zope.interface import implements
 
 class CreatorAnnotatorClass(object):
@@ -32,7 +32,7 @@
         # Try to find a principal for that one. If there
         # is no principal then we don't touch the list
         # of creators.
-        interaction = getInteraction()
+        interaction = queryInteraction()
         if interaction is not None:
             for participation in interaction.participations:
                 principalid = participation.principal.id

Modified: Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py	2004-05-14 13:41:59 UTC (rev 24648)
+++ Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py	2004-05-14 13:45:49 UTC (rev 24649)
@@ -33,7 +33,7 @@
 from zope.publisher.interfaces import IRequest, IPublishTraverse
 from zope.publisher.browser import BrowserResponse
 from zope.security import simplepolicies
-from zope.security.management import setSecurityPolicy, getInteraction
+from zope.security.management import setSecurityPolicy, queryInteraction
 
 from zope.app import zapi
 from zope.app.tests.placelesssetup import PlacelessSetup
@@ -370,7 +370,7 @@
         defineChecker(Folder, InterfaceChecker(IFolder))
 
         self.publication.beforeTraversal(self.request)
-        self.assertEqual(list(getInteraction().participations),
+        self.assertEqual(list(queryInteraction().participations),
                          [self.request])
         self.assertEqual(self.request.principal.id, 'anonymous')
         root = self.publication.getApplication(self.request)
@@ -382,7 +382,7 @@
         ob = self.publication.traverseName(self.request, ob, 'f2')
         self.publication.afterTraversal(self.request, ob)
         self.assertEqual(self.request.principal.id, 'test.bob')
-        self.assertEqual(list(getInteraction().participations),
+        self.assertEqual(list(queryInteraction().participations),
                          [self.request])
 
     def testTransactionCommitAfterCall(self):

Modified: Zope3/trunk/src/zope/app/workflow/stateful/instance.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/instance.py	2004-05-14 13:41:59 UTC (rev 24648)
+++ Zope3/trunk/src/zope/app/workflow/stateful/instance.py	2004-05-14 13:45:49 UTC (rev 24649)
@@ -38,7 +38,7 @@
 from zope.interface import directlyProvides, implements
 from zope.proxy import removeAllProxies
 from zope.schema import getFields
-from zope.security.management import getInteraction
+from zope.security.management import queryInteraction
 from zope.security.checker import CheckerPublic, Checker
 from zope.security.proxy import Proxy
 from zope.security import checkPermission
@@ -226,9 +226,9 @@
         # data should be readonly for condition-evaluation
         ctx['data'] = self.data
         ctx['principal'] = None
-        interaction = getInteraction()
+        interaction = queryInteraction()
         if interaction is not None:
-            principals = [p.principal for p in getInteraction().participations]
+            principals = [p.principal for p in interaction.participations]
             if principals:
                 # XXX There can be more than one principal
                 assert len(principals) == 1

Modified: Zope3/trunk/src/zope/security/__init__.py
===================================================================
--- Zope3/trunk/src/zope/security/__init__.py	2004-05-14 13:41:59 UTC (rev 24648)
+++ Zope3/trunk/src/zope/security/__init__.py	2004-05-14 13:45:49 UTC (rev 24649)
@@ -7,7 +7,7 @@
 import zope.proxy
 
 from zope.security.checker import CheckerPublic as _CheckerPublic
-from zope.security.management import getInteraction as _getInteraction
+from zope.security.management import queryInteraction as _queryInteraction
 from zope.security.management import getSecurityPolicy as _getSecurityPolicy
 
 def checkPermission(permission, object, interaction=None):
@@ -26,7 +26,7 @@
     if permission is None or permission is _CheckerPublic:
         return True
     if interaction is None:
-        interaction = _getInteraction()
+        interaction = _queryInteraction()
     policy = _getSecurityPolicy()
     return policy.checkPermission(permission, object, interaction)
 

Modified: Zope3/trunk/src/zope/security/checker.py
===================================================================
--- Zope3/trunk/src/zope/security/checker.py	2004-05-14 13:41:59 UTC (rev 24648)
+++ Zope3/trunk/src/zope/security/checker.py	2004-05-14 13:45:49 UTC (rev 24649)
@@ -37,7 +37,7 @@
 from zope.interface.declarations import Declaration
 from zope.security.interfaces import IChecker, INameBasedChecker
 from zope.security.interfaces import ISecurityProxyFactory
-from zope.security.management import getSecurityPolicy, getInteraction
+from zope.security.management import getSecurityPolicy, queryInteraction
 from zope.security._proxy import _Proxy as Proxy, getChecker
 from zope.exceptions import Unauthorized, ForbiddenAttribute, DuplicationError
 
@@ -144,7 +144,7 @@
             if permission is CheckerPublic:
                 return # Public
             policy = getSecurityPolicy()
-            interaction = getInteraction()
+            interaction = queryInteraction()
             if policy.checkPermission(permission, object, interaction):
                 return
             else:
@@ -161,7 +161,7 @@
             if permission is CheckerPublic:
                 return # Public
             policy = getSecurityPolicy()
-            interaction = getInteraction()
+            interaction = queryInteraction()
             if policy.checkPermission(permission, object, interaction):
                 return
             else:
@@ -306,7 +306,7 @@
             if permission is CheckerPublic:
                 return # Public
             policy = getSecurityPolicy()
-            interaction = getInteraction()
+            interaction = queryInteraction()
             if policy.checkPermission(permission, object, interaction):
                 return
             else:
@@ -324,7 +324,7 @@
             if permission is CheckerPublic:
                 return # Public
             policy = getSecurityPolicy()
-            interaction = getInteraction()
+            interaction = queryInteraction()
             if policy.checkPermission(permission, object, interaction):
                 return
             else:
@@ -342,7 +342,7 @@
             if permission is CheckerPublic:
                 return # Public
             policy = getSecurityPolicy()
-            interaction = getInteraction()
+            interaction = queryInteraction()
             if policy.checkPermission(permission, object, interaction):
                 return
             else:

Modified: Zope3/trunk/src/zope/security/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/security/interfaces.py	2004-05-14 13:41:59 UTC (rev 24648)
+++ Zope3/trunk/src/zope/security/interfaces.py	2004-05-14 13:45:49 UTC (rev 24649)
@@ -166,11 +166,10 @@
         Raises an error if the calling thread already has an interaction.
         """
 
-    def getInteraction():
+    def queryInteraction():
         """Return the current interaction.
 
-        Returns None if called outside newInteraction/endInteraction pair.
-        XXX should it raise an exception instead?
+        Returns None if there is no interaction.
         """
 
     def endInteraction():

Modified: Zope3/trunk/src/zope/security/management.py
===================================================================
--- Zope3/trunk/src/zope/security/management.py	2004-05-14 13:41:59 UTC (rev 24648)
+++ Zope3/trunk/src/zope/security/management.py	2004-05-14 13:45:49 UTC (rev 24649)
@@ -63,14 +63,14 @@
 #   IInteractionManagement implementation
 #
 
-def getInteraction(_thread=None):
+def queryInteraction(_thread=None):
     """Get the current interaction."""
     return thread_globals(_thread).interaction
 
 def newInteraction(participation=None, _thread=None, _policy=None):
     """Start a new interaction."""
-    if getInteraction(_thread) is not None:
-        stack = getInteraction(_thread)._newInteraction_called_from
+    if queryInteraction(_thread) is not None:
+        stack = queryInteraction(_thread)._newInteraction_called_from
         raise AssertionError("newInteraction called"
                              " while another interaction is active:\n%s"
                              % "".join(traceback.format_list(stack)))

Modified: Zope3/trunk/src/zope/security/tests/test_management.py
===================================================================
--- Zope3/trunk/src/zope/security/tests/test_management.py	2004-05-14 13:41:59 UTC (rev 24648)
+++ Zope3/trunk/src/zope/security/tests/test_management.py	2004-05-14 13:45:49 UTC (rev 24649)
@@ -41,9 +41,9 @@
         setSecurityPolicy(policy)
         self.assert_(getSecurityPolicy() is policy)
 
-    def test_getInteraction(self):
+    def test_queryInteraction(self):
         # XXX this test is a bit obfuscated
-        from zope.security.management import getInteraction
+        from zope.security.management import queryInteraction
 
         marker = object()
         class ThreadVars:
@@ -51,7 +51,7 @@
         class ThreadStub:
             __zope3_thread_globals__ = ThreadVars()
 
-        self.assert_(getInteraction(_thread=ThreadStub()) is marker)
+        self.assert_(queryInteraction(_thread=ThreadStub()) is marker)
 
     def test_newInteraction(self):
         # XXX this test is a bit obfuscated
@@ -90,7 +90,7 @@
     def test_checkPermission(self):
         from zope.security import checkPermission
         from zope.security.management import setSecurityPolicy
-        from zope.security.management import getInteraction
+        from zope.security.management import queryInteraction
         from zope.security.management import newInteraction
 
         permission = 'zope.Test'
@@ -107,7 +107,7 @@
             def checkPermission(s, p, o, i):
                 self.assert_(p is permission)
                 self.assert_(o is obj)
-                self.assert_(i is getInteraction() or i is interaction)
+                self.assert_(i is queryInteraction() or i is interaction)
                 return i is interaction
 
         setSecurityPolicy(PolicyStub())




More information about the Zope3-Checkins mailing list