]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
py:samdb: make SamDB.__str__ show the URL and ID
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 14 Mar 2024 01:15:47 +0000 (14:15 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 20 Mar 2024 23:42:34 +0000 (23:42 +0000)
Getting the right samdb is going to matter more, so it is useful for
debugging to see which is which.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/samdb.py

index 085dff43848253b81238da71fa375220131a0f03..b831cf562506e86cd0f527d466215f01c9765634 100644 (file)
@@ -104,6 +104,14 @@ class SamDB(samba.Ldb):
 
         super().connect(url=url, flags=flags, options=options)
 
+    def __repr__(self):
+        if self.url:
+            return f"<SamDB {id(self):x} ({self.url})>"
+
+        return f"<SamDB {id(self):x} (no connection)>"
+
+    __str__ = __repr__
+
     def am_rodc(self):
         """return True if we are an RODC"""
         return dsdb._am_rodc(self)