From 5aa3b4dd531cb6d904ae8a0ac5363c4d37d34afb Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Wed, 5 Jul 2023 14:49:41 +0200
Subject: [PATCH] REVERT: revert some refactoring in Message class

---
 CHANGELOG.md                |  3 +--
 src/caosdb/common/models.py | 15 ++++++++-------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0b0ef99d..4d42e0b2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,8 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ### Changed ###
 
 * `_Messages` is now `Messages` and inherits from list instead of dict
-* `Message.__init__` signature changed and expects a `description` now while
-  `type` defaults to "Info" now.
+* `Message.__init__` signature changed and `type` defaults to "Info" now.
 * `Message.__eq__` changed. Equality is equality of `type`, `code`, and
   `description` now.
 
diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py
index 697c3969..df77bb73 100644
--- a/src/caosdb/common/models.py
+++ b/src/caosdb/common/models.py
@@ -682,7 +682,8 @@ class Entity:
         if msg is not None:
             pass
         else:
-            msg = Message(type, code, description, body)
+            msg = Message(description=description, type=type, code=code,
+                          body=body)
         self.messages.append(msg)
 
         return self
@@ -1870,7 +1871,7 @@ class Property(Entity):
 
 class Message(object):
 
-    def __init__(self, description, type=None, code=None, body=None):  # @ReservedAssignment
+    def __init__(self, type=None, code=None, description=None, body=None):  # @ReservedAssignment
         self.description = description
         self.type = type if type is not None else "Info"
         self.code = int(code) if code is not None else None
@@ -3137,7 +3138,7 @@ class Container(list):
                     msg = "Request was not unique. CUID " + \
                         str(local_entity._cuid) + " was found " + \
                         str(len(sync_remote_entities)) + " times."
-                    local_entity.add_message(Message("Error", None, msg))
+                    local_entity.add_message(Message(description=msg, type="Error"))
 
                     if raise_exception_on_error:
                         raise MismatchingEntitiesError(msg)
@@ -3162,7 +3163,7 @@ class Container(list):
                     msg = "Request was not unique. ID " + \
                         str(local_entity.id) + " was found " + \
                         str(len(sync_remote_entities)) + " times."
-                    local_entity.add_message(Message("Error", None, msg))
+                    local_entity.add_message(Message(description=msg, type="Error"))
 
                     if raise_exception_on_error:
                         raise MismatchingEntitiesError(msg)
@@ -3192,7 +3193,7 @@ class Container(list):
                     msg = "Request was not unique. Path " + \
                         str(local_entity.path) + " was found " + \
                         str(len(sync_remote_entities)) + " times."
-                    local_entity.add_message(Message("Error", None, msg))
+                    local_entity.add_message(Message(description=msg, type="Error"))
 
                     if raise_exception_on_error:
                         raise MismatchingEntitiesError(msg)
@@ -3222,7 +3223,7 @@ class Container(list):
                     msg = "Request was not unique. Name " + \
                         str(local_entity.name) + " was found " + \
                         str(len(sync_remote_entities)) + " times."
-                    local_entity.add_message(Message("Error", None, msg))
+                    local_entity.add_message(Message(description=msg, type="Error"))
 
                     if raise_exception_on_error:
                         raise MismatchingEntitiesError(msg)
@@ -3241,7 +3242,7 @@ class Container(list):
             msg = "Request was not unique. There are " + \
                 str(len(sync_remote_entities)) + \
                 " entities which could not be matched to one of the requested ones."
-            remote_container.add_message(Message("Error", None, msg))
+            remote_container.add_message(Message(description=msg, type="Error"))
 
             if raise_exception_on_error:
                 raise MismatchingEntitiesError(msg)
-- 
GitLab