diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index 4acbcd1a0eed1bef32cd70d8625cef8b869a2a46..f9e6732d4f51aa11bde96791df2d103f2bcf14ed 100644 --- a/src/caosdb/common/models.py +++ b/src/caosdb/common/models.py @@ -2400,9 +2400,8 @@ class _ParentList(list): class Messages(list): - - """This 'kind of dictionary' stores error, warning, info, and other - messages. The mentioned three messages types are messages of special use. + """This specialization of list stores error, warning, info, and other + messages. The mentioned three messages types play a special role. They are generated by the client and the server while processing the entity to which the message in question belongs. It is RECOMMENDED NOT to specify such messages manually. The other messages are ignored by the server unless @@ -2413,13 +2412,6 @@ class Messages(list): <$Type code=$code description=$description>$body</$Type> - Messages are treated as 'equal' if and only if both they have the same type (case-insensitive), - and the same code (or no code). Every message - MUST NOT occur more than once per entity (to which the message in question belongs). - - If a message m2 is added while a messages m1 is already in this Message object m2 will - OVERRIDE m1. - Error, warning, and info messages will be deleted before any transaction. Examples: @@ -2442,25 +2434,6 @@ class Messages(list): <<< msgs.append(msg) <<< # get it back via get(...) and the key tuple (type, code) <<< assert id(msgs.get("HelloWorld",1))==id(msg) - - <<< # delete Message via remove and the (type,code) tuple - <<< msgs.remove("HelloWorld",1) - <<< assert msgs.get("HelloWorld",1) == None - - <<< # short version of adding/setting/resetting a new Message - <<< msgs["HelloWorld",2] = "Greeting the world in German", "Hallo, Welt!" - <<< assert msgs["HelloWorld",2] == ("Greeting the world in German","Hallo, Welt!") - <<< msgs["HelloWorld",2] = "Greeting the world in German", "Huhu, Welt!" - <<< assert msgs["HelloWorld",2] == ("Greeting the world in German","Huhu, Welt!") - <<< del msgs["HelloWorld",2] - <<< assert msgs.get("HelloWorld",2) == None - - # this Message has no code and no description (make easy things easy...) - <<< - <<< msgs["HelloWorld"] = "Hello!" - <<< assert msgs["HelloWorld"] == "Hello!" - - (to be continued...) """ def clear_server_messages(self): @@ -2637,7 +2610,8 @@ class Messages(list): return self.__hash__() == obj.__hash__() def __hash__(self): - return + return hash(str(self._type).lower() + (str(",") + str(self._code) + if self._code is not None else '')) def __repr__(self): return str(self._type) + (str(",") + str(self._code)