model: Uniqueness checks are not functional
Referable.update_from()
patches the self
object with the other
object by iterating over the attributes of the other
objects using the python built-in vars()
. vars()
only iterates over an objects attributes, not properties e.g. getter/setter functions. The id_short
attribute of Referable
is a property, which performs additional checks when setting the id_short
, such as checking for uniqueness within the namespace by searching the objects contained in the parent
object. The actual value of the id_short
is stored in the protected attribute _id_short
.
Since _id_short
is an attribute and id_short
is a property, the vars()
built-in returns the _id_short
attribute instead of the id_short
property, which causes update_from()
to update the _id_short
directly, skipping the setter function and thus the uniqueness check.
This is also the case for the semantic_id
property of HasSemantics
, which also checks for uniqueness.
A solution proposed by @sebastian.heppner and @mhthies is to add dictionaries to each class, mapping the protected attributes to the respective property. These dictionaries would then be searched by update_from()
, which can then set the property instead of the attribute.
Another issue is that this uniqueness check is not performed for objects contained in one or more AbstractObjectStore
, because these are not referenced by the parent
attribute.
The third and final issue is located in NamespaceSet.update_nss_from()
. [...]
Each fix has to be backported to the not yet existent V2.0
branch.
Progress Tracker:
-
Uniqueness not checked in Referable.update_from()
-
No uniqueness check for objects inside an AbstractObjectStore
-
NamespaceSet.update_nss_from()