Skip to content

Commit

Permalink
Improve check on created content ID
Browse files Browse the repository at this point in the history
We need to check for container field / attribute when trying to create content with same id
This refs #35
  • Loading branch information
laulaz committed Apr 18, 2023
1 parent 853e76b commit e736c4e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/35.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Check for container field / attribute when trying to create content with same id [laulaz]
4 changes: 4 additions & 0 deletions src/plone/base/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ def _check_for_collision(contained_by, cid, **kwargs):
mapping={"name": cid},
)

# containers may have a field / attribute of the same name
if base_hasattr(contained_by, cid):
return _("${name} is reserved.", mapping={"name": cid})

# containers may implement this hook to further restrict ids
if getattr(aq_base(contained_by), "checkValidId", _marker) is not _marker:
try:
Expand Down

0 comments on commit e736c4e

Please sign in to comment.