Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
91f27016
Commit
91f27016
authored
Jun 05, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed the deprecated ``hasRole`` method from user objects - 9 years should be enough ;)
parent
047f2030
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
117 deletions
+8
-117
doc/CHANGES.rst
doc/CHANGES.rst
+2
-0
src/AccessControl/User.py
src/AccessControl/User.py
+5
-43
src/AccessControl/tests/testDeprecatedAPI.py
src/AccessControl/tests/testDeprecatedAPI.py
+0
-72
src/DocumentTemplate/cDocumentTemplate.c
src/DocumentTemplate/cDocumentTemplate.c
+1
-2
No files found.
doc/CHANGES.rst
View file @
91f27016
...
@@ -11,6 +11,8 @@ Trunk (unreleased)
...
@@ -11,6 +11,8 @@ Trunk (unreleased)
Restructuring
Restructuring
+++++++++++++
+++++++++++++
-
Removed
the
deprecated
``
hasRole
``
method
from
user
objects
.
-
Removed
deprecated
support
for
specifying
``
__ac_permissions__
``,
-
Removed
deprecated
support
for
specifying
``
__ac_permissions__
``,
``
meta_types
``
and
``
methods
``
in
a
product
's ``__init__``.
``
meta_types
``
and
``
methods
``
in
a
product
's ``__init__``.
...
...
src/AccessControl/User.py
View file @
91f27016
...
@@ -244,19 +244,6 @@ class BasicUser(Implicit):
...
@@ -244,19 +244,6 @@ class BasicUser(Implicit):
break
break
return
None
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
=
[]
domains
=
[]
def
has_role
(
self
,
roles
,
object
=
None
):
def
has_role
(
self
,
roles
,
object
=
None
):
...
@@ -325,26 +312,15 @@ class UnrestrictedUser(SpecialUser):
...
@@ -325,26 +312,15 @@ class UnrestrictedUser(SpecialUser):
"""User that passes all security checks. Note, however, that modules
"""User that passes all security checks. Note, however, that modules
like Owner.py can still impose restrictions.
like Owner.py can still impose restrictions.
"""
"""
def
allowed
(
self
,
parent
,
roles
=
None
):
def
allowed
(
self
,
parent
,
roles
=
None
):
return
roles
is
not
_what_not_even_god_should_do
return
roles
is
not
_what_not_even_god_should_do
def
hasRole
(
self
,
*
args
,
**
kw
):
def
has_role
(
self
,
roles
,
object
=
None
):
"""hasRole is an alias for 'allowed' and has been deprecated.
return
1
Code still using this method should convert to either 'has_role' or
'allowed', depending on the intended behaviour.
"""
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
def
has_permission
(
self
,
permission
,
object
):
return
1
class
NullUnrestrictedUser
(
SpecialUser
):
class
NullUnrestrictedUser
(
SpecialUser
):
...
@@ -380,20 +356,6 @@ class NullUnrestrictedUser(SpecialUser):
...
@@ -380,20 +356,6 @@ class NullUnrestrictedUser(SpecialUser):
def
allowed
(
self
,
parent
,
roles
=
None
):
def
allowed
(
self
,
parent
,
roles
=
None
):
return
0
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
):
def
has_role
(
self
,
roles
,
object
=
None
):
return
0
return
0
...
...
src/AccessControl/tests/testDeprecatedAPI.py
deleted
100644 → 0
View file @
047f2030
##############################################################################
#
# 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
src/DocumentTemplate/cDocumentTemplate.c
View file @
91f27016
...
@@ -19,7 +19,7 @@ static char cDocumentTemplate_module_documentation[] =
...
@@ -19,7 +19,7 @@ static char cDocumentTemplate_module_documentation[] =
static
PyObject
*
py_isDocTemp
=
0
,
*
py_blocks
=
0
,
*
py_
=
0
,
*
join
=
0
,
*
py_acquire
;
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___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_Unauthorized_fmt
,
*
py_guarded_getattr
;
static
PyObject
*
py__push
,
*
py__pop
,
*
py_aq_base
,
*
py_renderNS
;
static
PyObject
*
py__push
,
*
py__pop
,
*
py_aq_base
,
*
py_renderNS
;
static
PyObject
*
py___class__
,
*
html_quote
,
*
ustr
,
*
untaint_name
;
static
PyObject
*
py___class__
,
*
html_quote
,
*
ustr
,
*
untaint_name
;
...
@@ -986,7 +986,6 @@ initcDocumentTemplate(void)
...
@@ -986,7 +986,6 @@ initcDocumentTemplate(void)
UNLESS
(
py___call__
=
PyString_FromString
(
"__call__"
))
return
;
UNLESS
(
py___call__
=
PyString_FromString
(
"__call__"
))
return
;
UNLESS
(
py___roles__
=
PyString_FromString
(
"__roles__"
))
return
;
UNLESS
(
py___roles__
=
PyString_FromString
(
"__roles__"
))
return
;
UNLESS
(
py__proxy_roles
=
PyString_FromString
(
"_proxy_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_guarded_getattr
=
PyString_FromString
(
"guarded_getattr"
))
return
;
UNLESS
(
py__push
=
PyString_FromString
(
"_push"
))
return
;
UNLESS
(
py__push
=
PyString_FromString
(
"_push"
))
return
;
UNLESS
(
py__pop
=
PyString_FromString
(
"_pop"
))
return
;
UNLESS
(
py__pop
=
PyString_FromString
(
"_pop"
))
return
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment