]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
netcmd: models: model __json__ method should call as_dict instead
authorRob van der Linde <rob@catalyst.net.nz>
Mon, 26 Feb 2024 00:45:54 +0000 (13:45 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 1 Mar 2024 04:45:36 +0000 (04:45 +0000)
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 <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/netcmd/domain/models/model.py

index 0e1f242ce9614533eb419cf70a5ed6c761201e62..b9b5b9c2a94e518885eb26b0837e19e12faad812 100644 (file)
@@ -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):