From 7aa7832cbb2782471b53124d594ada66fac357d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <henrik@trineo.org>
Date: Sun, 22 Sep 2019 20:03:58 +0200
Subject: [PATCH] force

---
 src/caosadvancedtools/cfood.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/caosadvancedtools/cfood.py b/src/caosadvancedtools/cfood.py
index 1310919d..94eada6f 100644
--- a/src/caosadvancedtools/cfood.py
+++ b/src/caosadvancedtools/cfood.py
@@ -280,7 +280,8 @@ def assure_object_is_in_list(obj, containing_object, property_name,
         to_be_updated.append(containing_object)
 
 
-def assure_has_parent(entity, parent, to_be_updated=None, verbosity=INFO):
+def assure_has_parent(entity, parent, to_be_updated=None, verbosity=INFO,
+                      force=False):
     """
     Checks whether `entity` has a parent with name `parent`.
 
@@ -314,7 +315,13 @@ def assure_has_parent(entity, parent, to_be_updated=None, verbosity=INFO):
     if to_be_updated is None:
         get_ids_for_entities_with_names([entity])
 
-        guard.safe_update(entity, unique=False)
+        # TODO move the unique argument?
+        # TODO  find a better way then force?
+
+        if force:
+            entity.update(unique=False)
+        else:
+            guard.safe_update(entity, unique=False)
     else:
         to_be_updated.append(entity)
 
-- 
GitLab