From: Rob van der Linde Date: Mon, 26 Feb 2024 00:45:54 +0000 (+1300) Subject: netcmd: models: model __json__ method should call as_dict instead X-Git-Tag: tdb-1.4.11~1571 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=982ebebfbe15221c2d4f8d9611426ae0a06e2bd5;p=thirdparty%2Fsamba.git netcmd: models: model __json__ method should call as_dict instead The comment about RelatedField is not really relevant so removed that part, RelatedField isn't used at this point. The idea with RelatedField is that it fetches the object (vs DnField which just returns a Dn). Signed-off-by: Rob van der Linde Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/python/samba/netcmd/domain/models/model.py b/python/samba/netcmd/domain/models/model.py index 0e1f242ce96..b9b5b9c2a94 100644 --- a/python/samba/netcmd/domain/models/model.py +++ b/python/samba/netcmd/domain/models/model.py @@ -111,13 +111,8 @@ class Model(metaclass=ModelMeta): return self.dn == other.dn def __json__(self): - """Automatically called by custom JSONEncoder class. - - When turning an object into json any fields of type RelatedField - will also end up calling this method. - """ - if self.dn is not None: - return str(self.dn) + """Automatically called by custom JSONEncoder class.""" + return self.as_dict() @staticmethod def get_base_dn(ldb):