Skip to content

Commit

Permalink
Merge pull request #535 from plone/fix-create-relation-none
Browse files Browse the repository at this point in the history
In relation.create, handle existing value of None
  • Loading branch information
davisagli committed Apr 30, 2024
2 parents f2ac29a + 5677a0c commit 7dc8997
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/535.bugfix
@@ -0,0 +1 @@
In relation.create: Fix edge case where existing RelationList value is None. @davisagli
2 changes: 1 addition & 1 deletion src/plone/api/relation.py
Expand Up @@ -217,7 +217,7 @@ def create(source=None, target=None, relationship=None):
target.absolute_url(),
)
if not has_relation:
existing_relations = getattr(source, from_attribute, [])
existing_relations = getattr(source, from_attribute, None) or []
existing_relations.append(RelationValue(to_id))
setattr(source, from_attribute, existing_relations)
modified(source)
Expand Down

0 comments on commit 7dc8997

Please sign in to comment.