[Zope3-checkins] SVN: Zope3/branches/mgedmin-security/src/zope/app/workflow/stateful/ Changed workflow to use getInteraction instead of getSecurityManager.

Marius Gedminas marius at pov.lt
Wed May 12 16:28:37 EDT 2004


Log message for revision 24607:
Changed workflow to use getInteraction instead of getSecurityManager.




-=-
Modified: Zope3/branches/mgedmin-security/src/zope/app/workflow/stateful/instance.py
===================================================================
--- Zope3/branches/mgedmin-security/src/zope/app/workflow/stateful/instance.py	2004-05-12 20:21:50 UTC (rev 24606)
+++ Zope3/branches/mgedmin-security/src/zope/app/workflow/stateful/instance.py	2004-05-12 20:28:36 UTC (rev 24607)
@@ -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 getSecurityManager
+from zope.security.management import getInteraction
 from zope.security.checker import CheckerPublic, Checker
 from zope.security.proxy import Proxy
 from zope.security import checkPermission
@@ -225,7 +225,14 @@
         ctx = {}
         # data should be readonly for condition-evaluation
         ctx['data'] = self.data
-        ctx['principal'] = getSecurityManager().getPrincipal()
+        ctx['principal'] = None
+        interaction = getInteraction()
+        if interaction is not None:
+            principals = [p.principal for p in getInteraction().participations]
+            if principals:
+                # XXX There can be more than one principal
+                assert len(principals) == 1
+                ctx['principal'] = principals[0]
 
         # XXX This needs to be discussed:
         # how can we know if this ProcessInstance is annotated

Modified: Zope3/branches/mgedmin-security/src/zope/app/workflow/stateful/tests/test_instance.py
===================================================================
--- Zope3/branches/mgedmin-security/src/zope/app/workflow/stateful/tests/test_instance.py	2004-05-12 20:21:50 UTC (rev 24606)
+++ Zope3/branches/mgedmin-security/src/zope/app/workflow/stateful/tests/test_instance.py	2004-05-12 20:28:36 UTC (rev 24607)
@@ -27,7 +27,7 @@
 from zope.app.security.interfaces import IPermission
 from zope.app.security.permission import Permission
 from zope.security.checker import CheckerPublic
-from zope.security.management import newSecurityManager
+from zope.security.management import newInteraction
 
 from zope.app.annotation.interfaces import IAttributeAnnotatable
 from zope.app.registration.interfaces import IRegisterable
@@ -55,6 +55,13 @@
 from zope.app.utility import UtilityRegistration
 
 
+class ParticipationStub:
+
+    def __init__(self, principal):
+        self.principal = principal
+        self.interaction = None
+
+
 # define and create ProcessDefinition (PD) for tests
 class TestProcessDefinition(StatefulProcessDefinition):
     implements(IAttributeAnnotatable)
@@ -358,7 +365,7 @@
 
         ztapi.provideUtility(IPermission, Permission('deny', 'Deny'), 'deny')
 
-        newSecurityManager('test')
+        newInteraction(ParticipationStub('test'))
 
         pd = TestProcessDefinition()
 




More information about the Zope3-Checkins mailing list