Log message for revision 113173: Removed the deprecated ``hasRole`` method from user objects - 9 years should be enough ;)
Changed: U Zope/trunk/doc/CHANGES.rst U Zope/trunk/src/AccessControl/User.py D Zope/trunk/src/AccessControl/tests/testDeprecatedAPI.py U Zope/trunk/src/DocumentTemplate/cDocumentTemplate.c -=- Modified: Zope/trunk/doc/CHANGES.rst =================================================================== --- Zope/trunk/doc/CHANGES.rst 2010-06-05 20:23:38 UTC (rev 113172) +++ Zope/trunk/doc/CHANGES.rst 2010-06-05 22:14:10 UTC (rev 113173) @@ -11,6 +11,8 @@ Restructuring +++++++++++++ +- Removed the deprecated ``hasRole`` method from user objects. + - Removed deprecated support for specifying ``__ac_permissions__``, ``meta_types`` and ``methods`` in a product's ``__init__``. Modified: Zope/trunk/src/AccessControl/User.py =================================================================== --- Zope/trunk/src/AccessControl/User.py 2010-06-05 20:23:38 UTC (rev 113172) +++ Zope/trunk/src/AccessControl/User.py 2010-06-05 22:14:10 UTC (rev 113173) @@ -244,19 +244,6 @@ break return None - def hasRole(self, *args, **kw): - """hasRole is an alias for 'allowed' and has been deprecated. - - Code still using this method should convert to either 'has_role' or - 'allowed', depending on the intended behaviour. - - """ - import warnings - warnings.warn('BasicUser.hasRole is deprecated, please use ' - 'BasicUser.allowed instead; hasRole was an alias for allowed, but ' - 'you may have ment to use has_role.', DeprecationWarning) - return self.allowed(*args, **kw) - domains=[] def has_role(self, roles, object=None): @@ -325,28 +312,17 @@ """User that passes all security checks. Note, however, that modules like Owner.py can still impose restrictions. """ + def allowed(self,parent,roles=None): return roles is not _what_not_even_god_should_do - def hasRole(self, *args, **kw): - """hasRole is an alias for 'allowed' and has been deprecated. + def has_role(self, roles, object=None): + return 1 - Code still using this method should convert to either 'has_role' or - 'allowed', depending on the intended behaviour. + def has_permission(self, permission, object): + return 1 - """ - import warnings - warnings.warn('UnrestrictedUser.hasRole is deprecated, please use ' - 'UnrestrictedUser.allowed instead; hasRole was an alias for ' - 'allowed, but you may have ment to use has_role.', - DeprecationWarning) - self.allowed(*args, **kw) - def has_role(self, roles, object=None): return 1 - - def has_permission(self, permission, object): return 1 - - class NullUnrestrictedUser(SpecialUser): """User created if no emergency user exists. It is only around to satisfy third party userfolder implementations that may @@ -380,20 +356,6 @@ def allowed(self, parent, roles=None): return 0 - def hasRole(self, *args, **kw): - """hasRole is an alias for 'allowed' and has been deprecated. - - Code still using this method should convert to either 'has_role' or - 'allowed', depending on the intended behaviour. - - """ - import warnings - warnings.warn('NullUnrestrictedUser.hasRole is deprecated, please use ' - 'NullUnrestrictedUser.allowed instead; hasRole was an alias for ' - 'allowed, but you may have ment to use has_role.', - DeprecationWarning) - self.allowed(*args, **kw) - def has_role(self, roles, object=None): return 0 Deleted: Zope/trunk/src/AccessControl/tests/testDeprecatedAPI.py =================================================================== --- Zope/trunk/src/AccessControl/tests/testDeprecatedAPI.py 2010-06-05 20:23:38 UTC (rev 113172) +++ Zope/trunk/src/AccessControl/tests/testDeprecatedAPI.py 2010-06-05 22:14:10 UTC (rev 113173) @@ -1,72 +0,0 @@ -############################################################################## -# -# Copyright (c) 2002 Zope Foundation and Contributors. -# -# 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 -# -############################################################################## -"""Tests for the DeprecationWarning thrown by accessing hasRole - -To be removed together with the API in due time. - -""" - -__rcs_id__='$Id$' -__version__='$Revision: 1.6 $'[11:-2] - -import ZODB # Sigh. Persistent needs to be set, so we import ZODB. -from AccessControl import User -import unittest, warnings - -class DeprecatedAPI(unittest.TestCase): - def setUp(self): - # There is no official API to restore warning filters to a previous - # state. Here we cheat. - self.original_warning_filters = warnings.filters[:] - - # We test for warnings by turning them into exceptions - warnings.filterwarnings('error', category=DeprecationWarning, - module='AccessControl') - - def tearDown(self): - warnings.filters[:] = self.original_warning_filters - - def testDeprecatedHasRole(self): - # hasRole has been deprecated, we expect a warning. - try: - self.userObject.hasRole(None) - except DeprecationWarning: - pass - else: - self.fail('Expected DeprecationWarning, none given') - - def testAllowed(self): - # hasRole is an alias for allowed, which should be unaffected. - try: - self.userObject.allowed(None) - except DeprecationWarning: - self.fail('Unexpected DeprecationWarning, ' - 'no warnings expected here') - else: - pass - -class BasicUser(DeprecatedAPI): - userObject = User.SimpleUser('JoeBloke', '123', [], []) - -class UnrestrictedUser(DeprecatedAPI): - userObject = User.UnrestrictedUser('Special', '123', [], []) - -class NullUnrestrictedUser(DeprecatedAPI): - userObject = User.NullUnrestrictedUser() - -def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(BasicUser)) - suite.addTest(unittest.makeSuite(UnrestrictedUser)) - suite.addTest(unittest.makeSuite(NullUnrestrictedUser)) - return suite Modified: Zope/trunk/src/DocumentTemplate/cDocumentTemplate.c =================================================================== --- Zope/trunk/src/DocumentTemplate/cDocumentTemplate.c 2010-06-05 20:23:38 UTC (rev 113172) +++ Zope/trunk/src/DocumentTemplate/cDocumentTemplate.c 2010-06-05 22:14:10 UTC (rev 113173) @@ -19,7 +19,7 @@ static PyObject *py_isDocTemp=0, *py_blocks=0, *py_=0, *join=0, *py_acquire; static PyObject *py___call__, *py___roles__, *py_AUTHENTICATED_USER; -static PyObject *py_hasRole, *py__proxy_roles, *py_Unauthorized; +static PyObject *py__proxy_roles, *py_Unauthorized; static PyObject *py_Unauthorized_fmt, *py_guarded_getattr; static PyObject *py__push, *py__pop, *py_aq_base, *py_renderNS; static PyObject *py___class__, *html_quote, *ustr, *untaint_name; @@ -986,7 +986,6 @@ UNLESS(py___call__=PyString_FromString("__call__")) return; UNLESS(py___roles__=PyString_FromString("__roles__")) return; UNLESS(py__proxy_roles=PyString_FromString("_proxy_roles")) return; - UNLESS(py_hasRole=PyString_FromString("hasRole")) return; UNLESS(py_guarded_getattr=PyString_FromString("guarded_getattr")) return; UNLESS(py__push=PyString_FromString("_push")) return; UNLESS(py__pop=PyString_FromString("_pop")) return; _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins