Author: jelmer Date: 2007-10-14 18:57:47 +0000 (Sun, 14 Oct 2007) New Revision: 25637
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25637 Log: Allow late connects. 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:54:46 UTC (rev 25636) +++ branches/4.0-python/source/lib/ldb/swig/ldb.i 2007-10-14 18:57:47 UTC (rev 25637) @@ -70,12 +70,6 @@ "ldb context must be non-NULL"); } -%typemap(check) const char *url { - if ($1 == NULL) - SWIG_exception(SWIG_ValueError, - "url can not be None"); -} - /* * Wrap a small bit of talloc */ @@ -256,15 +250,18 @@ /* Top-level ldb operations */ typedef struct ldb_context { %extend { - ldb(const char *url, unsigned int flags = 0, + ldb(const char *url=NULL, unsigned int flags = 0, const char *options[] = NULL) { ldb *ldb = ldb_init(NULL); - int ret; + + if (url != NULL) { + int ret; - ret = ldb_connect(ldb, url, flags, options); - if (ret != LDB_SUCCESS) - SWIG_exception(SWIG_ValueError, ldb_errstring(ldb)); + ret = ldb_connect(ldb, url, flags, options); + if (ret != LDB_SUCCESS) + SWIG_exception(SWIG_ValueError, ldb_errstring(ldb)); + } return ldb; @@ -272,6 +269,10 @@ talloc_free(ldb); return NULL; } + + int connect(const char *url, unsigned int flags = 0, + const char *options[] = NULL); + ~ldb() { talloc_free($self); } int search(ldb_dn *base = NULL, enum ldb_scope scope = LDB_SCOPE_DEFAULT, 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:54:46 UTC (rev 25636) +++ branches/4.0-python/source/lib/ldb/tests/python/api.py 2007-10-14 18:57:47 UTC (rev 25637) @@ -13,8 +13,12 @@ ldb.Ldb("foo.tdb") def test_connect_none(self): - self.assertRaises(ValueError, ldb.Ldb, None) + ldb.Ldb() + def test_connect_later(self): + x = ldb.Ldb() + x.connect("foo.tdb") + def test_search(self): l = ldb.Ldb("foo.tdb") self.assertEquals(len(l.search()), 1)
