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
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
8aeb134c
Commit
8aeb134c
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
6b85d617
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 @
8aeb134c
...
...
@@ -1180,7 +1180,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
...
...
@@ -1194,16 +1199,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 @
8aeb134c
...
...
@@ -2684,7 +2684,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'
))
...
...
@@ -2696,6 +2696,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'
))
def
test_edit
(
self
):
self
.
_addProperty
(
'Person'
,
...
...
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