From 1de90b02cdd7a4e05c6e32e03a99279420fbe030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20K=C3=BCrten?= Date: Thu, 17 Apr 2025 15:26:07 +0200 Subject: [PATCH 1/3] fix: link_objects function to handle individual BaseObject fields, not only lists --- csfunctions/handler.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/csfunctions/handler.py b/csfunctions/handler.py index 8ef8a10..a1e7266 100644 --- a/csfunctions/handler.py +++ b/csfunctions/handler.py @@ -77,6 +77,10 @@ def link_objects(event: Event): # the list might contain entries that are not objects, so we check first if isinstance(obj, BaseObject): obj.link_objects(data) + elif isinstance(field, BaseObject): + # if the field is not a list, we check if it is an object and link it + field.link_objects(data) + # if the field is not a list or an object, we ignore it def execute(function_name: str, request_body: str, function_dir: str = "src") -> str: From 6e81385152dd696e9eca138184715432207b15f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20K=C3=BCrten?= Date: Thu, 17 Apr 2025 15:50:21 +0200 Subject: [PATCH 2/3] fix comment --- csfunctions/handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/csfunctions/handler.py b/csfunctions/handler.py index a1e7266..fea1c54 100644 --- a/csfunctions/handler.py +++ b/csfunctions/handler.py @@ -68,8 +68,8 @@ def link_objects(event: Event): # e.g. all parts would be in Event.data.parts = list[Part] for field_name in data.model_fields_set: - # go through each field in data and look for fields that are lists - # objects will always be passed in a list + # go through each field in data and look for fields that are lists of BaseObjects + # or direct BaseObjects field = getattr(data, field_name) if isinstance(field, list): From e6a84cdf583d42316d8b54c35cb9ff8e2caa4298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20K=C3=BCrten?= Date: Thu, 17 Apr 2025 15:51:39 +0200 Subject: [PATCH 3/3] remove redundant comments --- csfunctions/handler.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/csfunctions/handler.py b/csfunctions/handler.py index fea1c54..9b8e770 100644 --- a/csfunctions/handler.py +++ b/csfunctions/handler.py @@ -78,9 +78,7 @@ def link_objects(event: Event): if isinstance(obj, BaseObject): obj.link_objects(data) elif isinstance(field, BaseObject): - # if the field is not a list, we check if it is an object and link it field.link_objects(data) - # if the field is not a list or an object, we ignore it def execute(function_name: str, request_body: str, function_dir: str = "src") -> str: