to_save: list[str] = []
to_save_versioned: list[str] = []
to_save_relations: list[tuple[str, str, str, int]] = []
+ add_to_dict: list[str] = []
id_: None | BaseModelId
cache_: dict[BaseModelId, Self]
to_search: list[str] = []
for rel in getattr(self, attr_name):
l += [rel.as_dict_into_reference(library)]
d[attr_name] = l
+ for k in self.add_to_dict:
+ d[k] = [x.as_dict_into_reference(library)
+ for x in getattr(self, k)]
return d
def as_dict_into_reference(self,
assert isinstance(as_dict['id'], (int, str))
return as_dict['id']
+ @classmethod
+ def name_lowercase(cls) -> str:
+ """Convenience method to return cls' name in lowercase."""
+ return cls.__name__.lower()
+
# cache management
# (we primarily use the cache to ensure we work on the same object in
# memory no matter where and how we retrieve it, e.g. we don't want