summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/ldb.i8
-rw-r--r--source4/lib/ldb/ldb.py7
-rwxr-xr-xsource4/lib/ldb/tests/python/api.py4
3 files changed, 19 insertions, 0 deletions
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
index 2604393e8f..560142eb6d 100644
--- a/source4/lib/ldb/ldb.i
+++ b/source4/lib/ldb/ldb.i
@@ -201,6 +201,14 @@ fail:
/* FIXME: implement __getslice__ */
#endif
+ %pythoncode {
+ def __eq__(self, other):
+ if isinstance(other, self.__class__):
+ return self.__cmp__(other) == 0
+ if isinstance(other, str):
+ return str(self) == other
+ return False
+ }
}
} ldb_dn;
diff --git a/source4/lib/ldb/ldb.py b/source4/lib/ldb/ldb.py
index 4cc8b5268a..ab2a68a4b3 100644
--- a/source4/lib/ldb/ldb.py
+++ b/source4/lib/ldb/ldb.py
@@ -71,6 +71,13 @@ class Dn(object):
def __init__(self, *args, **kwargs):
_ldb.Dn_swiginit(self,_ldb.new_Dn(*args, **kwargs))
__swig_destroy__ = _ldb.delete_Dn
+ def __eq__(self, other):
+ if isinstance(other, self.__class__):
+ return self.__cmp__(other) == 0
+ if isinstance(other, str):
+ return str(self) == other
+ return False
+
Dn.validate = new_instancemethod(_ldb.Dn_validate,None,Dn)
Dn.get_casefold = new_instancemethod(_ldb.Dn_get_casefold,None,Dn)
Dn.__str__ = new_instancemethod(_ldb.Dn___str__,None,Dn)
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index b071b84b19..d5346c30b0 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -249,6 +249,10 @@ class DnTests(unittest.TestCase):
def setUp(self):
self.ldb = ldb.Ldb("foo.tdb")
+ def test_eq_str(self):
+ x = ldb.Dn(self.ldb, "dc=foo,bar=bloe")
+ self.assertEquals("dc=foo,bar=bloe", x)
+
def test_str(self):
x = ldb.Dn(self.ldb, "dc=foo,bar=bloe")
self.assertEquals(x.__str__(), "dc=foo,bar=bloe")