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
a3639de7
Commit
a3639de7
authored
Aug 23, 2012
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport `rolesForPermissionOn` fix from standalone AccessControl project
parent
12632a55
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
10 deletions
+62
-10
doc/CHANGES.rst
doc/CHANGES.rst
+3
-0
src/AccessControl/ZopeSecurityPolicy.py
src/AccessControl/ZopeSecurityPolicy.py
+5
-4
src/AccessControl/tests/testZopeSecurityPolicy.py
src/AccessControl/tests/testZopeSecurityPolicy.py
+54
-6
No files found.
doc/CHANGES.rst
View file @
a3639de7
...
@@ -8,6 +8,9 @@ http://docs.zope.org/zope2/releases/.
...
@@ -8,6 +8,9 @@ http://docs.zope.org/zope2/releases/.
2.12.24 (unreleased)
2.12.24 (unreleased)
--------------------
--------------------
- Fix a bug in ZopeSecurityPolicy.py. Global variable `rolesForPermissionOn`
could be overridden if `__role__` had custom rolesForPermissionOn.
- Updated distributions:
- Updated distributions:
- zdaemon = 2.0.7
- zdaemon = 2.0.7
...
...
src/AccessControl/ZopeSecurityPolicy.py
View file @
a3639de7
...
@@ -52,9 +52,10 @@ def getRoles(container, name, value, default):
...
@@ -52,9 +52,10 @@ def getRoles(container, name, value, default):
if
roles
is
None
or
isinstance
(
roles
,
tuple_or_list
):
if
roles
is
None
or
isinstance
(
roles
,
tuple_or_list
):
return
roles
return
roles
rolesForPermissionOn
=
getattr
(
roles
,
'rolesForPermissionOn'
,
None
)
# Do not override global variable `rolesForPermissionOn`.
if
rolesForPermissionOn
is
not
None
:
roles_rolesForPermissionOn
=
getattr
(
roles
,
'rolesForPermissionOn'
,
None
)
roles
=
rolesForPermissionOn
(
value
)
if
roles_rolesForPermissionOn
is
not
None
:
roles
=
roles_rolesForPermissionOn
(
value
)
return
roles
return
roles
src/AccessControl/tests/testZopeSecurityPolicy.py
View file @
a3639de7
...
@@ -10,13 +10,11 @@
...
@@ -10,13 +10,11 @@
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Tests of ZopeSecurityPolicy
"""
__rcs_id__
=
'$Id$'
import
os
__version__
=
'$Revision: 1.10 $'
[
11
:
-
2
]
import
sys
import
thread
import
os
,
sys
,
unittest
import
unittest
import
ZODB
import
ZODB
try
:
try
:
...
@@ -576,11 +574,61 @@ def test_zsp_gets_right_roles_for_methods():
...
@@ -576,11 +574,61 @@ def test_zsp_gets_right_roles_for_methods():
from
doctest
import
DocTestSuite
from
doctest
import
DocTestSuite
class
GetRolesWithMultiThreadTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
_original_check_interval
=
sys
.
getcheckinterval
()
sys
.
setcheckinterval
(
1
)
def
tearDown
(
self
):
sys
.
setcheckinterval
(
self
.
_original_check_interval
)
def
testGetRolesWithMultiThread
(
self
):
from
AccessControl.ZopeSecurityPolicy
import
getRoles
class
C
(
object
):
pass
class
V1
(
object
):
class
__roles__
(
object
):
@
staticmethod
def
rolesForPermissionOn
(
ob
):
return
[
'Member'
]
class
V2
(
object
):
class
__roles__
(
object
):
@
staticmethod
def
rolesForPermissionOn
(
ob
):
return
[
'User'
]
c
=
C
()
c
.
v1
=
V1
()
c
.
v2
=
V2
()
self
.
assertEqual
(
getRoles
(
c
,
None
,
c
.
v1
,
42
),
[
'Member'
])
self
.
assertEqual
(
getRoles
(
c
,
None
,
c
.
v2
,
42
),
[
'User'
])
mark
=
[]
def
loop
():
while
1
:
getRoles
(
c
,
None
,
c
.
v2
,
42
)
if
len
(
mark
)
>
0
:
return
thread
.
start_new_thread
(
loop
,
())
try
:
for
i
in
range
(
1000
):
self
.
assertEqual
(
getRoles
(
c
,
None
,
c
.
v1
,
42
),
[
'Member'
])
finally
:
mark
.
append
(
None
)
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
Python_ZSPTests
,
'test'
))
suite
.
addTest
(
unittest
.
makeSuite
(
Python_ZSPTests
,
'test'
))
suite
.
addTest
(
unittest
.
makeSuite
(
C_ZSPTests
,
'test'
))
suite
.
addTest
(
unittest
.
makeSuite
(
C_ZSPTests
,
'test'
))
suite
.
addTest
(
DocTestSuite
())
suite
.
addTest
(
DocTestSuite
())
suite
.
addTest
(
unittest
.
makeSuite
(
GetRolesWithMultiThreadTest
))
return
suite
return
suite
def
main
():
def
main
():
...
...
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