From 6710e860d3bb1b364682f31bdae6b3bcb8b33b16 Mon Sep 17 00:00:00 2001
From: Alexander Schlemmer <alexander@mail-schlemmer.de>
Date: Fri, 4 Mar 2022 18:24:14 +0100
Subject: [PATCH] MAINT: removed obsolete last id attribute and function

---
 src/caosdb/high_level_api.py | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/src/caosdb/high_level_api.py b/src/caosdb/high_level_api.py
index 66e07a62..f3235894 100644
--- a/src/caosdb/high_level_api.py
+++ b/src/caosdb/high_level_api.py
@@ -111,8 +111,6 @@ class CaosDBPythonUnresolvedReference(CaosDBPythonUnresolved):
 
 class CaosDBPythonEntity(object):
 
-    _last_id = 0
-
     def __init__(self):
         """
         Initialize a new CaosDBPythonEntity for the high level python api.
@@ -146,6 +144,10 @@ class CaosDBPythonEntity(object):
         # which must not be changed by the set_property function.
         self._forbidden = dir(self) + ["_forbidden"]
 
+    def use_parameter(self, name, value):
+        self.__setattr__(name, value)
+        return value
+
     @property
     def id(self):
         """
@@ -224,17 +226,6 @@ class CaosDBPythonEntity(object):
     def version(self, val: str):
         self._version = val
 
-    # @staticmethod
-    # def _get_new_id():
-    #     """
-    #     Get a new negative ID for a CaosDB Entity.
-
-    #     The first ID is -1 and decremented with each call of this function.
-    #     """
-    #     CaosDBPythonEntity._last_id -= 1
-
-    #     return CaosDBPythonEntity._last_id
-
     def _set_property_from_entity(self, ent: db.Entity, importance: str,
                                   references: Optional[db.Container]):
         """
@@ -709,6 +700,8 @@ def _single_convert_to_python_object(robj: CaosDBPythonEntity,
     for base_attribute in BASE_ATTRIBUTES:
         val = entity.__getattribute__(base_attribute)
         if val is not None:
+            if isinstance(val, db.common.models.Version):
+                val = val.id
             robj.__setattr__(base_attribute, val)
 
     for prop in entity.properties:
-- 
GitLab