[Zope3-checkins]
SVN: Zope3/branches/mgedmin-security/src/zope/app/dublincore/
Changed CreatorAnnotator to use getInteraction instead of
getSecurityManager.
Marius Gedminas
marius at pov.lt
Wed May 12 16:18:58 EDT 2004
Log message for revision 24605:
Changed CreatorAnnotator to use getInteraction instead of getSecurityManager.
-=-
Modified: Zope3/branches/mgedmin-security/src/zope/app/dublincore/creatorannotator.py
===================================================================
--- Zope3/branches/mgedmin-security/src/zope/app/dublincore/creatorannotator.py 2004-05-12 20:00:38 UTC (rev 24604)
+++ Zope3/branches/mgedmin-security/src/zope/app/dublincore/creatorannotator.py 2004-05-12 20:18:57 UTC (rev 24605)
@@ -17,7 +17,7 @@
"""
from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.event.interfaces import ISubscriber
-from zope.security.management import getSecurityManager
+from zope.security.management import getInteraction
from zope.interface import implements
class CreatorAnnotatorClass(object):
@@ -32,11 +32,11 @@
# Try to find a principal for that one. If there
# is no principal then we don't touch the list
# of creators.
- principal = getSecurityManager().getPrincipal()
- if principal is None:
- return
- principalid = principal.id
- if not principalid in dc.creators:
- dc.creators = dc.creators + (unicode(principalid), )
+ interaction = getInteraction()
+ if interaction is not None:
+ for participation in interaction.participations:
+ principalid = participation.principal.id
+ if not principalid in dc.creators:
+ dc.creators = dc.creators + (unicode(principalid), )
CreatorAnnotator = CreatorAnnotatorClass()
Modified: Zope3/branches/mgedmin-security/src/zope/app/dublincore/tests/test_creatorannotator.py
===================================================================
--- Zope3/branches/mgedmin-security/src/zope/app/dublincore/tests/test_creatorannotator.py 2004-05-12 20:00:38 UTC (rev 24604)
+++ Zope3/branches/mgedmin-security/src/zope/app/dublincore/tests/test_creatorannotator.py 2004-05-12 20:18:57 UTC (rev 24605)
@@ -26,7 +26,7 @@
from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.security.interfaces import IPrincipal
from zope.app.event.interfaces import IEvent
-from zope.security.management import noSecurityManager, newSecurityManager
+from zope.security.management import newInteraction, endInteraction
class IDummyContent(Interface):
pass
@@ -65,16 +65,20 @@
self.title = title
self.description = description
+class DummyRequest:
+ def __init__(self, principal):
+ self.principal = principal
+ self.interaction = None
+
+
class Test(PlacefulSetup, TestCase, CleanUp):
def setUp(self):
PlacefulSetup.setUp(self)
ztapi.provideAdapter(IDummyContent, IZopeDublinCore, DummyDCAdapter)
- noSecurityManager()
def tearDown(self):
- noSecurityManager()
PlacefulSetup.tearDown(self)
def test_creatorannotation(self):
@@ -91,33 +95,37 @@
'this is a very bad author')
# Check what happens if no user is there
- noSecurityManager()
+ newInteraction(None)
CreatorAnnotator.notify(event)
self.assertEqual(data.creators,())
+ endInteraction()
# Let the bad edit it first
- security = newSecurityManager(bad_author)
+ newInteraction(DummyRequest(bad_author))
CreatorAnnotator.notify(event)
self.failIf(len(data.creators) != 1)
self.failUnless(bad_author.id in data.creators)
+ endInteraction()
# Now let the good edit it
- security = newSecurityManager(good_author)
+ newInteraction(DummyRequest(good_author))
CreatorAnnotator.notify(event)
self.failIf(len(data.creators) != 2)
self.failUnless(good_author.id in data.creators)
self.failUnless(bad_author.id in data.creators)
+ endInteraction()
# Let the bad edit it again
- security = newSecurityManager(bad_author)
+ newInteraction(DummyRequest(bad_author))
CreatorAnnotator.notify(event)
# Check that the bad author hasn't been added twice.
self.failIf(len(data.creators) != 2)
self.failUnless(good_author.id in data.creators)
self.failUnless(bad_author.id in data.creators)
+ endInteraction()
def test_suite():
return TestSuite((
More information about the Zope3-Checkins
mailing list