Skip to content

Commit

Permalink
Fix api.content.get when a item in the path is not acccessible to the…
Browse files Browse the repository at this point in the history
… user (#549)
  • Loading branch information
pbauer committed Dec 20, 2024
1 parent d8c716b commit 5c732ea
Show file tree
Hide file tree
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 acccessible 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
Expand Up @@ -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:
Expand Down

0 comments on commit 5c732ea

Please sign in to comment.