svn commit: samba r25636 - in branches/4.0-python: . source/lib/ldb/swig source/lib/ldb/tests/python

jelmer at samba.org jelmer at samba.org
Sun Oct 14 18:54:47 GMT 2007


Author: jelmer
Date: 2007-10-14 18:54:46 +0000 (Sun, 14 Oct 2007)
New Revision: 25636

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25636

Log:
Implement + for dn's, canonical_str() and canonical_ex_str().
Modified:
   branches/4.0-python/
   branches/4.0-python/source/lib/ldb/swig/ldb.i
   branches/4.0-python/source/lib/ldb/tests/python/api.py


Changeset:

Property changes on: branches/4.0-python
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/4.0-python/source/lib/ldb/swig/ldb.i
===================================================================
--- branches/4.0-python/source/lib/ldb/swig/ldb.i	2007-10-14 18:39:39 UTC (rev 25635)
+++ branches/4.0-python/source/lib/ldb/swig/ldb.i	2007-10-14 18:54:46 UTC (rev 25636)
@@ -155,6 +155,22 @@
         int get_comp_num();
         bool add_child(ldb_dn *child);
         bool add_base(ldb_dn *base);
+        const char *canonical_str() {
+            return ldb_dn_canonical_string($self, $self);
+        }
+        const char *canonical_ex_str() {
+            return ldb_dn_canonical_ex_string($self, $self);
+        }
+#ifdef SWIGPYTHON
+        ldb_dn *__add__(ldb_dn *other)
+        {
+            ldb_dn *ret = ldb_dn_copy(NULL, $self);
+            ldb_dn_add_child(ret, other);
+            return ret;
+        }
+
+        /* FIXME: implement __getslice__ */
+#endif
     }
 } ldb_dn;
 
@@ -182,6 +198,7 @@
                 return NULL;
             }
 
+            /* Python << 2.5 doesn't have PySet_New and PySet_Add. */
             result = PyObject_CallObject(&PySet_Type, NULL);
 
             for (i = 0; i < ret->num_values; i++) {

Modified: branches/4.0-python/source/lib/ldb/tests/python/api.py
===================================================================
--- branches/4.0-python/source/lib/ldb/tests/python/api.py	2007-10-14 18:39:39 UTC (rev 25635)
+++ branches/4.0-python/source/lib/ldb/tests/python/api.py	2007-10-14 18:54:46 UTC (rev 25636)
@@ -103,6 +103,20 @@
         self.assertTrue(x.add_base(ldb.Dn(self.ldb, "bla=bloe")))
         self.assertEquals("dc=foo,bar=bloe,bla=bloe", x.__str__())
 
+    def test_add(self):
+        x = ldb.Dn(self.ldb, "dc=foo")
+        y = ldb.Dn(self.ldb, "bar=bla")
+        self.assertEquals("dc=foo,bar=bla", str(y + x))
+
+    def test_canonical_string(self):
+        x = ldb.Dn(self.ldb, "dc=foo,bar=bloe")
+        self.assertEquals("/bloe/foo", x.canonical_str())
+
+    def test_canonical_ex_string(self):
+        x = ldb.Dn(self.ldb, "dc=foo,bar=bloe")
+        self.assertEquals("/bloe\nfoo", x.canonical_ex_str())
+
+
 class LdbMsgTests(unittest.TestCase):
     def setUp(self):
         self.msg = ldb.Message()



More information about the samba-cvs mailing list