Skip to content

Commit

Permalink
Fix api.content.get when a item in the path is not accessible to the …
Browse files Browse the repository at this point in the history
…user (#549)
pbauer committed Dec 20, 2024
1 parent d8c716b commit 0da4d70
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions news/549.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix api.content.get(path=path) when a item in the path is not accessible to the user.
[pbauer]
7 changes: 6 additions & 1 deletion src/plone/api/content.py
Original file line number Diff line number Diff line change
@@ -133,7 +133,12 @@ def get(path=None, UID=None):
relative_path=path,
)
try:
content = site.restrictedTraverse(path)
path = path.split("/")
if len(path) > 1:
parent = site.unrestrictedTraverse(path[:-1])
content = parent.restrictedTraverse(path[-1])
else:
content = site.restrictedTraverse(path[-1])
except (KeyError, AttributeError):
return None # When no object is found don't raise an error
else:

0 comments on commit 0da4d70

Please sign in to comment.