[Checkins] SVN: zope.securitypolicy/trunk/ Relocate security settings from zope.app.security

Christian Theune ct at gocept.com
Thu Jan 29 15:47:44 EST 2009


Log message for revision 95527:
  Relocate security settings from zope.app.security
  

Changed:
  U   zope.securitypolicy/trunk/CHANGES.txt
  A   zope.securitypolicy/trunk/src/zope/securitypolicy/settings.py
  A   zope.securitypolicy/trunk/src/zope/securitypolicy/tests/test_settings.py

-=-
Modified: zope.securitypolicy/trunk/CHANGES.txt
===================================================================
--- zope.securitypolicy/trunk/CHANGES.txt	2009-01-29 20:18:38 UTC (rev 95526)
+++ zope.securitypolicy/trunk/CHANGES.txt	2009-01-29 20:47:44 UTC (rev 95527)
@@ -5,7 +5,7 @@
 3.4.3 (unreleased)
 ------------------
 
-- ...
+- Include settings that were previously imported from zope.app.security.
 
 3.4.2 (2009-01-28)
 ------------------

Copied: zope.securitypolicy/trunk/src/zope/securitypolicy/settings.py (from rev 95325, zope.app.security/trunk/src/zope/app/security/settings.py)
===================================================================
--- zope.securitypolicy/trunk/src/zope/securitypolicy/settings.py	                        (rev 0)
+++ zope.securitypolicy/trunk/src/zope/securitypolicy/settings.py	2009-01-29 20:47:44 UTC (rev 95527)
@@ -0,0 +1,79 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Security setting constants.
+
+The `Allow`, `Deny`, and `Unset` constants are exposed by the
+`zope.app.securitypolicy.interfaces` module, and should be imported
+from there.
+
+$Id$
+"""
+
+# The location of this module within the package hierarchy is an
+# accident of implementation.  This may change; see the issue:
+# http://www.zope.org/Collectors/Zope3-dev/712
+
+
+class PermissionSetting(object):
+    """PermissionSettings should be considered as immutable.
+    They can be compared by identity. They are identified by
+    their name.
+    """
+
+    def __new__(cls, name, description=None):
+        """Keep a dict of PermissionSetting instances, indexed by
+        name. If the name already exists in the dict, return that
+        instance rather than creating a new one.
+        """
+        instances = cls.__dict__.get('__instances__')
+        if instances is None:
+            cls.__instances__ = instances = {}
+        it = instances.get(name)
+        if it is None:
+            instances[name] = it = object.__new__(cls)
+            it._init(name, description)
+        return it
+
+    def _init(self, name, description):
+        self.__name = name
+        self.__description = description
+
+    def getDescription(self):
+        return self.__description
+
+    def getName(self):
+        return self.__name
+
+    def __str__(self):
+        return "PermissionSetting: %s" % self.__name
+
+    __repr__ = __str__
+
+# register PermissionSettings to be symbolic constants by identity,
+# even when pickled and unpickled.
+import copy_reg
+copy_reg.constructor(PermissionSetting)
+copy_reg.pickle(PermissionSetting,
+                PermissionSetting.getName,
+                PermissionSetting)
+
+
+Allow = PermissionSetting('Allow',
+    'Explicit allow setting for permissions')
+
+Deny = PermissionSetting('Deny',
+    'Explicit deny setting for permissions')
+
+Unset = PermissionSetting('Unset',
+    'Unset constant that denotes no setting for permission')


Property changes on: zope.securitypolicy/trunk/src/zope/securitypolicy/settings.py
___________________________________________________________________
Added: cvs2svn:cvs-rev
   + 1.4
Added: svn:keywords
   + Id
Added: svn:mergeinfo
   + 
Added: svn:eol-style
   + native

Copied: zope.securitypolicy/trunk/src/zope/securitypolicy/tests/test_settings.py (from rev 95325, zope.app.security/trunk/src/zope/app/security/tests/test_settings.py)
===================================================================
--- zope.securitypolicy/trunk/src/zope/securitypolicy/tests/test_settings.py	                        (rev 0)
+++ zope.securitypolicy/trunk/src/zope/securitypolicy/tests/test_settings.py	2009-01-29 20:47:44 UTC (rev 95527)
@@ -0,0 +1,41 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Security Settings Tests
+
+$Id$
+"""
+import unittest
+
+from zope.app.security.settings import Allow
+from cPickle import Pickler, Unpickler
+from StringIO import StringIO
+
+class Test(unittest.TestCase):
+
+    def testPickleUnpickle(self):
+        s = StringIO()
+        p = Pickler(s)
+        p.dump(Allow)
+        s.seek(0)
+        u = Unpickler(s)
+        newAllow = u.load()
+
+        self.failUnless(newAllow is Allow)
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(Test)
+
+if __name__=='__main__':
+    unittest.TextTestRunner().run(test_suite())


Property changes on: zope.securitypolicy/trunk/src/zope/securitypolicy/tests/test_settings.py
___________________________________________________________________
Added: cvs2svn:cvs-rev
   + 1.4
Added: svn:keywords
   + Id
Added: svn:mergeinfo
   + 
Added: svn:eol-style
   + native



More information about the Checkins mailing list