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

jelmer at samba.org jelmer at samba.org
Mon Oct 15 13:29:12 GMT 2007


Author: jelmer
Date: 2007-10-15 13:29:11 +0000 (Mon, 15 Oct 2007)
New Revision: 25653

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

Log:
Support passing in arrays of attribute names.
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-15 13:29:08 UTC (rev 25652)
+++ branches/4.0-python/source/lib/ldb/swig/ldb.i	2007-10-15 13:29:11 UTC (rev 25653)
@@ -112,6 +112,24 @@
         );
     }
 }
+
+%typemap(in, numinputs=1) const char * const *attrs {
+    /* FIXME: read $input and convert to $1 */
+    if ($input == Py_None) {
+        $1 = NULL;
+    } else if (PySequence_Check($input)) {
+        int i;
+        $1 = talloc_array(NULL, const char *, PySequence_Size($input));
+        for(i = 0; i < PySequence_Size($input); i++)
+            $1[i] = PyString_AsString(PySequence_GetItem($input, i));
+    } else {
+        SWIG_exception(SWIG_TypeError, "expected sequence");
+    }
+}
+
+%typemap(freearg) const char * const *attrs {
+    talloc_free($1);
+}
 #endif
 
 %types(struct ldb_result *);

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-15 13:29:08 UTC (rev 25652)
+++ branches/4.0-python/source/lib/ldb/tests/python/api.py	2007-10-15 13:29:11 UTC (rev 25653)
@@ -28,6 +28,10 @@
         l = ldb.Ldb("foo.tdb")
         self.assertEquals(len(l.search()), 1)
 
+    def test_search_attrs(self):
+        l = ldb.Ldb("foo.tdb")
+        self.assertEquals(len(l.search(ldb.Dn(l, ""), ldb.SCOPE_SUBTREE, "(dc=*)", ["dc"])), 0)
+
     def test_search_scope_base(self):
         l = ldb.Ldb("foo.tdb")
         self.assertEquals(len(l.search(ldb.Dn(l, "dc=foo"), 



More information about the samba-cvs mailing list