[Zope3-checkins] SVN: Zope3/branches/mgedmin-security/src/zope/security/ Get rid of ISecurityManagement.

Marius Gedminas marius at pov.lt
Wed May 12 17:38:08 EDT 2004


Log message for revision 24614:
Get rid of ISecurityManagement.




-=-
Modified: Zope3/branches/mgedmin-security/src/zope/security/interfaces.py
===================================================================
--- Zope3/branches/mgedmin-security/src/zope/security/interfaces.py	2004-05-12 21:33:46 UTC (rev 24613)
+++ Zope3/branches/mgedmin-security/src/zope/security/interfaces.py	2004-05-12 21:38:07 UTC (rev 24614)
@@ -18,29 +18,6 @@
 from zope.interface import Interface, Attribute
 
 
-class ISecurityManagementSetup(Interface):  # XXX: going away
-    """Methods to manage the security manager.
-
-    Infrastructure (including tests, etc.) calls these things to
-    tweak the security manager.
-    """
-
-    def newSecurityManager(user):
-        """Install a new SecurityManager, using user.
-
-        Return the old SecurityManager, if any, or None.
-        """
-
-    def replaceSecurityManager(old_manager):
-        """Replace the SecurityManager with old_manager.
-
-        old_manager must implement ISecurityManager.
-        """
-
-    def noSecurityManager():
-        """Clear any existing SecurityManager."""
-
-
 class ISecurityManagement(Interface):
     """Public security management API."""
 

Modified: Zope3/branches/mgedmin-security/src/zope/security/management.py
===================================================================
--- Zope3/branches/mgedmin-security/src/zope/security/management.py	2004-05-12 21:33:46 UTC (rev 24613)
+++ Zope3/branches/mgedmin-security/src/zope/security/management.py	2004-05-12 21:38:07 UTC (rev 24614)
@@ -23,58 +23,16 @@
 
 from zope.interface import moduleProvides
 from zope.security.interfaces import ISecurityManagement
-from zope.security.interfaces import ISecurityManagementSetup
 from zope.security.interfaces import IInteractionManagement
-from zope.security.manager import SecurityManager
 from zope.security.manager import setSecurityPolicy as _setSecurityPolicy
 from zope.security.manager import getSecurityPolicy as _getSecurityPolicy
-from zope.security.context import SecurityContext
 from zope.testing.cleanup import addCleanUp
 from zope.thread import thread_globals
 
-moduleProvides(ISecurityManagement, ISecurityManagementSetup,
-               IInteractionManagement)
+moduleProvides(ISecurityManagement, IInteractionManagement)
 
-try:
-    import thread
-except:
-    get_ident = lambda: 0
-else:
-    get_ident = thread.get_ident
 
-_managers = {}
-
-from zope.testing.cleanup import addCleanUp
-addCleanUp(_managers.clear)
-
 #
-#   ISecurityManagementSetup implementation
-#
-def newSecurityManager(user):
-    """Install a new SecurityManager, using user.
-
-    Return the old SecurityManager, if any, or None.
-    """
-    return replaceSecurityManager(SecurityManager(SecurityContext(user)))
-
-def replaceSecurityManager(old_manager):
-    """Replace the SecurityManager with 'old_manager', which must
-    implement ISecurityManager.
-    """
-
-    thread_id = get_ident()
-    old = _managers.get(thread_id, None)
-    _managers[thread_id] = old_manager
-    return old
-
-def noSecurityManager():
-    """Clear any existing SecurityManager."""
-    try:
-        del _managers[get_ident()]
-    except KeyError:
-        pass
-
-#
 #   ISecurityManagement implementation
 #
 

Modified: Zope3/branches/mgedmin-security/src/zope/security/tests/test_management.py
===================================================================
--- Zope3/branches/mgedmin-security/src/zope/security/tests/test_management.py	2004-05-12 21:33:46 UTC (rev 24613)
+++ Zope3/branches/mgedmin-security/src/zope/security/tests/test_management.py	2004-05-12 21:38:07 UTC (rev 24614)
@@ -21,54 +21,17 @@
 from zope.interface.verify import verifyObject
 from zope.testing.cleanup import CleanUp
 
-from zope.security.management import noSecurityManager, newSecurityManager
-from zope.security.management import setSecurityPolicy
 
-
 class Test(CleanUp, unittest.TestCase):
 
     def test_import(self):
         from zope.security import management
         from zope.security.interfaces import ISecurityManagement
-        from zope.security.interfaces \
-            import ISecurityManagementSetup
         from zope.security.interfaces import IInteractionManagement
 
-        verifyObject(ISecurityManagementSetup, management)
         verifyObject(ISecurityManagement, management)
         verifyObject(IInteractionManagement, management)
 
-    def test_ISecurityManagementSetup(self):
-
-        from zope.security.management import noSecurityManager
-        from zope.security.management import newSecurityManager
-        from zope.security.management import replaceSecurityManager
-
-        some_user = []
-        other_user = []
-        old = newSecurityManager(some_user)
-        self.assertEqual(old, None)
-
-        old = newSecurityManager(other_user)
-        self.failUnless(old is not None)
-        self.failUnless(old.getPrincipal() is some_user)
-
-        old2 = replaceSecurityManager(old)
-        self.failUnless(old2 is not None)
-        self.failUnless(old2.getPrincipal() is other_user)
-
-        noSecurityManager()
-
-    def _setPermissive(self):
-        from zope.security.management import setSecurityPolicy
-        from zope.security.simplepolicies import PermissiveSecurityPolicy
-        setSecurityPolicy(PermissiveSecurityPolicy())
-
-    def _setParanoid(self):
-        from zope.security.management import setSecurityPolicy
-        from zope.security.simplepolicies import ParanoidSecurityPolicy
-        setSecurityPolicy(ParanoidSecurityPolicy())
-
     def test_securityPolicy(self):
         from zope.security.management import setSecurityPolicy
         from zope.security.management import getSecurityPolicy




More information about the Zope3-Checkins mailing list