[Checkins] SVN: zope.app.security/trunk/ Finish moving of security constants to zope.securitypolicy.
Dan Korostelev
nadako at gmail.com
Mon Mar 9 20:47:21 EDT 2009
Log message for revision 97750:
Finish moving of security constants to zope.securitypolicy.
Changed:
U zope.app.security/trunk/CHANGES.txt
U zope.app.security/trunk/src/zope/app/security/configure.zcml
U zope.app.security/trunk/src/zope/app/security/settings.py
D zope.app.security/trunk/src/zope/app/security/tests/test_settings.py
-=-
Modified: zope.app.security/trunk/CHANGES.txt
===================================================================
--- zope.app.security/trunk/CHANGES.txt 2009-03-10 00:43:20 UTC (rev 97749)
+++ zope.app.security/trunk/CHANGES.txt 2009-03-10 00:47:21 UTC (rev 97750)
@@ -5,7 +5,13 @@
3.6.2 (unreleased)
------------------
-- ...
+- The `Allow`, `Deny` and `Unset` permission settings was preferred to
+ be imported from ``zope.securitypolicy.interfaces`` for a long time
+ and now they are completely moved there from ``zope.app.security.settings``
+ as well as the ``PermissionSetting`` class. The only thing left for
+ backward compatibility is the import of Allow/Unset/Deny constants if
+ ``zope.securitypolicy`` is installed to allow unpickling of security
+ settings.
3.6.1 (2009-03-09)
------------------
Modified: zope.app.security/trunk/src/zope/app/security/configure.zcml
===================================================================
--- zope.app.security/trunk/src/zope/app/security/configure.zcml 2009-03-10 00:43:20 UTC (rev 97749)
+++ zope.app.security/trunk/src/zope/app/security/configure.zcml 2009-03-10 00:47:21 UTC (rev 97750)
@@ -68,13 +68,6 @@
/>
</class>
- <class class=".settings.PermissionSetting">
- <require
- permission="zope.Public"
- attributes="getName getDescription __str__"
- />
- </class>
-
<adapter factory=".NoLogout" />
<!-- Standard Permissions -->
Modified: zope.app.security/trunk/src/zope/app/security/settings.py
===================================================================
--- zope.app.security/trunk/src/zope/app/security/settings.py 2009-03-10 00:43:20 UTC (rev 97749)
+++ zope.app.security/trunk/src/zope/app/security/settings.py 2009-03-10 00:47:21 UTC (rev 97750)
@@ -11,69 +11,18 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Security setting constants.
+"""Backward-compatibility import for security policy constants to allow
+unpickling of old pickled security settings.
-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')
+try:
+ from zope.securitypolicy.settings import Allow, Deny, Unset
+except ImportError:
+ import logging
+ logging.error('Allow, Unset and Deny constants are now '
+ 'moved from zope.app.security.settings to '
+ 'zope.securitypolicy.settings and you don\'t '
+ 'seem to have it installed. This is very rare '
+ 'case and you should manually install '
+ 'the ``zope.securitypolicy`` package.')
Deleted: zope.app.security/trunk/src/zope/app/security/tests/test_settings.py
===================================================================
--- zope.app.security/trunk/src/zope/app/security/tests/test_settings.py 2009-03-10 00:43:20 UTC (rev 97749)
+++ zope.app.security/trunk/src/zope/app/security/tests/test_settings.py 2009-03-10 00:47:21 UTC (rev 97750)
@@ -1,41 +0,0 @@
-##############################################################################
-#
-# 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())
More information about the Checkins
mailing list