Open juditnovak opened 4 months ago
Summary of the offline conversation with @welpaolo :
dict
for *Data
classes. i.e. no *Data.as_dict()
method (as the POC has it at the time this comment is written).
We agreed that it seems a good idea, as this allows for instantiating the object directly, instead of requiring a second object to benefit from dict
access (i.e. X
instance, Y = X.as_dict()
).dict
would become our confirmed interface for Abstract Relation Data.
dict
has a (breaking) change, it's likely to have a strong impact on the rest of our code anyway. So adjusting Relation Data may just be part of handling the problem overall.dict
IS a key-value mapping, it should ever correspond to the representation of Relation Data from our perspective. Thus overall it should be convenient to be used as an interface.@welpaolo I was an idiot. (Let's hope it's past tense :rofl: )
We need two separate objects.
Data
(here still called DataRelation
) is bound to a relation-name.
While the dict
is representing a specific relation within that "name".
So we can't do better than as_dict(relation_id)
:-/
Sorry I was thinking on a wrong track :-/
See how it works on ZooKeeper: https://github.com/canonical/zookeeper-operator/pull/122
If the concept is welcome, I'm adding the tests