Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
144
Merge Requests
144
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
2ca87ec8
Commit
2ca87ec8
authored
Oct 14, 2016
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Type: honor read_property in Base.getProperty
parent
c3f0585c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
7 deletions
+22
-7
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+16
-6
product/ERP5Type/tests/testERP5Type.py
product/ERP5Type/tests/testERP5Type.py
+6
-1
No files found.
product/ERP5Type/Base.py
View file @
2ca87ec8
...
...
@@ -1220,7 +1220,12 @@ class Base( CopyContainer,
accessor_name
=
'get'
+
UpperCase
(
key
)
aq_self
=
aq_base
(
self
)
if
getattr
(
aq_self
,
accessor_name
,
None
)
is
not
None
:
method
=
getattr
(
self
,
accessor_name
)
try
:
method
=
guarded_getattr
(
self
,
accessor_name
)
except
Unauthorized
:
if
not
kw
.
get
(
'checked_permission'
):
raise
return
None
if
d
is
_MARKER
else
d
if
d
is
not
_MARKER
:
try
:
# here method is a method defined on the class, we don't know if the
...
...
@@ -1234,16 +1239,21 @@ class Base( CopyContainer,
# and return it as a list
if
accessor_name
.
endswith
(
'List'
):
mono_valued_accessor_name
=
accessor_name
[:
-
4
]
method
=
getattr
(
self
.
__class__
,
mono_valued_accessor_name
,
None
)
if
method
is
not
None
:
if
getattr
(
self
.
__class__
,
mono_valued_accessor_name
,
None
)
is
not
None
:
try
:
method
=
guarded_getattr
(
self
,
mono_valued_accessor_name
)
except
Unauthorized
:
if
not
kw
.
get
(
'checked_permission'
):
raise
return
[]
if
d
is
_MARKER
else
d
# We have a monovalued property
if
d
is
_MARKER
:
result
=
method
(
self
,
**
kw
)
result
=
method
(
**
kw
)
else
:
try
:
result
=
method
(
self
,
d
,
**
kw
)
result
=
method
(
d
,
**
kw
)
except
TypeError
:
result
=
method
(
self
,
**
kw
)
result
=
method
(
**
kw
)
if
not
isinstance
(
result
,
(
list
,
tuple
)):
result
=
[
result
]
return
result
...
...
product/ERP5Type/tests/testERP5Type.py
View file @
2ca87ec8
...
...
@@ -2688,7 +2688,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
write_permission
=
'Set own password'
,
read_permission
=
'Manage users'
,
portal_type
=
'Standard Property'
)
obj
=
self
.
getPersonModule
().
newContent
(
portal_type
=
'Person'
)
obj
=
self
.
getPersonModule
().
newContent
(
portal_type
=
'Person'
,
foo_bar
=
'value'
)
self
.
assertTrue
(
guarded_hasattr
(
obj
,
'setFooBar'
))
self
.
assertTrue
(
guarded_hasattr
(
obj
,
'getFooBar'
))
...
...
@@ -2700,6 +2700,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
obj
.
manage_permission
(
'Manage users'
,
[],
0
)
self
.
assertTrue
(
guarded_hasattr
(
obj
,
'setFooBar'
))
self
.
assertFalse
(
guarded_hasattr
(
obj
,
'getFooBar'
))
# getProperty also raises
self
.
assertRaises
(
Unauthorized
,
obj
.
getProperty
,
'foo_bar'
)
# ... unless called with checked_permission=
self
.
assertEqual
(
None
,
obj
.
getProperty
(
'foo_bar'
,
checked_permission
=
'Access content information'
))
# Make sure that we can use 'Access contents information' as
# write permission and 'Modify portal content' as read permission.
...
...
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