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
a843fd52
Commit
a843fd52
authored
May 19, 2010
by
Jens Vagelpohl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- LP #142451: If non-recursive ownership changes are made using
``changeOwnership``, do not touch any children.
parent
775d9eab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
12 deletions
+98
-12
doc/CHANGES.rst
doc/CHANGES.rst
+3
-0
src/AccessControl/Owned.py
src/AccessControl/Owned.py
+9
-11
src/AccessControl/tests/testOwned.py
src/AccessControl/tests/testOwned.py
+86
-1
No files found.
doc/CHANGES.rst
View file @
a843fd52
...
...
@@ -162,6 +162,9 @@ Features Added
Bugs
Fixed
++++++++++
-
LP
#
142451
:
If
non
-
recursive
ownership
changes
are
made
using
``
changeOwnership
``,
do
not
touch
any
children
.
-
LP
#
142563
:
Fix
``
AccessControl
.
User
.
NullUnrestrictedUserTests
.
__str__
``.
-
LP
#
267820
:
Fix
bad
except
clause
in
the
``
sequence_sort
``
method
of
...
...
src/AccessControl/Owned.py
View file @
a843fd52
...
...
@@ -157,23 +157,21 @@ class Owned(Base):
If 'recursive' is true then also take ownership of all sub-objects,
otherwise sub-objects retain their ownership information.
"""
new
=
ownerInfo
(
user
)
if
new
is
None
:
return
# Special user!
new
=
ownerInfo
(
user
)
if
new
is
None
:
return
# Special user!
old
=
self
.
getOwnerTuple
()
if
not
recursive
:
if
old
==
new
:
return
if
old
is
UnownableOwner
:
return
if
old
==
new
or
old
is
UnownableOwner
:
return
for
child
in
self
.
objectValues
()
:
if
recursive
:
if
recursive
:
for
child
in
self
.
objectValues
()
:
child
.
changeOwnership
(
user
,
1
)
else
:
# make ownership explicit
child
.
_owner
=
new
if
old
is
not
UnownableOwner
:
self
.
_owner
=
new
self
.
_owner
=
new
def
userCanTakeOwnership
(
self
):
security
=
getSecurityManager
()
...
...
src/AccessControl/tests/testOwned.py
View file @
a843fd52
...
...
@@ -177,8 +177,93 @@ class OwnedTests(unittest.TestCase):
self
.
assertEqual
(
wrapped_owner
.
getId
(),
'user'
)
class
OwnershipChangeTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
from
AccessControl.Owned
import
UnownableOwner
from
AccessControl.User
import
UserFolder
from
OFS.Folder
import
Folder
super
(
OwnershipChangeTests
,
self
).
setUp
()
self
.
root
=
FauxRoot
()
self
.
root
.
acl_users
=
UserFolder
()
self
.
uf
=
self
.
root
.
acl_users
self
.
uf
.
_doAddUser
(
'user1'
,
'xxx'
,
[
'role1'
],
[])
self
.
uf
.
_doAddUser
(
'user2'
,
'xxx'
,
[
'role1'
],
[])
self
.
root
.
unownable
=
Folder
(
'unownable'
)
self
.
root
.
unownable
.
_owner
=
UnownableOwner
self
.
root
.
parent
=
Folder
(
'parent'
)
parent
=
self
.
root
.
parent
parent
.
_owner
=
([
'acl_users'
],
'user1'
)
parent
.
_setObject
(
'child'
,
Folder
(
'child'
))
parent
.
child
.
_owner
=
([
'acl_users'
],
'user1'
)
parent
.
child
.
_setObject
(
'grandchild'
,
Folder
(
'grandchild'
))
parent
.
child
.
grandchild
.
_owner
=
([
'acl_users'
],
'user1'
)
def
test_changeOwnership_bad_owner
(
self
):
from
AccessControl.User
import
nobody
previous
=
self
.
root
.
parent
.
_owner
self
.
root
.
parent
.
changeOwnership
(
nobody
)
self
.
assertEquals
(
self
.
root
.
parent
.
_owner
,
previous
)
def
test_changeOwnership_same_owner
(
self
):
previous
=
self
.
root
.
parent
.
_owner
sameuser
=
self
.
uf
.
getUser
(
'user1'
).
__of__
(
self
.
uf
)
self
.
root
.
parent
.
changeOwnership
(
sameuser
)
self
.
assertEquals
(
self
.
root
.
parent
.
_owner
,
previous
)
def
test_changeOwnership_unownable_owner
(
self
):
previous
=
self
.
root
.
unownable
.
_owner
newuser
=
self
.
uf
.
getUser
(
'user1'
).
__of__
(
self
.
uf
)
self
.
root
.
unownable
.
changeOwnership
(
newuser
)
self
.
assertEquals
(
self
.
root
.
unownable
.
_owner
,
previous
)
def
test_changeOwnership_nonrecursive
(
self
):
previous_parent_owner
=
self
.
root
.
parent
.
_owner
previous_child_owner
=
self
.
root
.
parent
.
child
.
_owner
previous_grandchild_owner
=
self
.
root
.
parent
.
child
.
grandchild
.
_owner
newuser
=
self
.
uf
.
getUser
(
'user2'
).
__of__
(
self
.
uf
)
self
.
root
.
parent
.
changeOwnership
(
newuser
)
self
.
assertNotEquals
(
self
.
root
.
parent
.
_owner
,
previous_parent_owner
)
self
.
assertEquals
(
self
.
root
.
parent
.
_owner
,
([
'acl_users'
],
'user2'
))
self
.
assertEquals
(
self
.
root
.
parent
.
child
.
_owner
,
previous_child_owner
)
self
.
assertEquals
(
self
.
root
.
parent
.
child
.
grandchild
.
_owner
,
previous_grandchild_owner
)
def
test_changeOwnership_recursive
(
self
):
previous_parent_owner
=
self
.
root
.
parent
.
_owner
previous_child_owner
=
self
.
root
.
parent
.
child
.
_owner
previous_grandchild_owner
=
self
.
root
.
parent
.
child
.
grandchild
.
_owner
newuser
=
self
.
uf
.
getUser
(
'user2'
).
__of__
(
self
.
uf
)
self
.
root
.
parent
.
changeOwnership
(
newuser
,
recursive
=
True
)
self
.
assertNotEquals
(
self
.
root
.
parent
.
_owner
,
previous_parent_owner
)
self
.
assertEquals
(
self
.
root
.
parent
.
_owner
,
([
'acl_users'
],
'user2'
))
self
.
assertNotEquals
(
self
.
root
.
parent
.
child
.
_owner
,
previous_child_owner
)
self
.
assertEquals
(
self
.
root
.
parent
.
child
.
_owner
,
([
'acl_users'
],
'user2'
)
)
self
.
assertNotEquals
(
self
.
root
.
parent
.
child
.
grandchild
.
_owner
,
previous_grandchild_owner
)
self
.
assertEquals
(
self
.
root
.
parent
.
child
.
grandchild
.
_owner
,
([
'acl_users'
],
'user2'
)
)
def
test_suite
():
return
unittest
.
makeSuite
(
OwnedTests
)
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
OwnedTests
),
unittest
.
makeSuite
(
OwnershipChangeTests
),
))
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
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