summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-05-19 23:12:13 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-05-19 23:12:13 +0200
commit43a22c9b4a7868a740e2de417f50702209d2aced (patch)
treea6e819c6658a3c5e52706c230c2b56a5ccd30e5f /source4/lib
parentae4611909609b8a0466938171812f10974dc054a (diff)
downloadsamba-43a22c9b4a7868a740e2de417f50702209d2aced.tar.gz
samba-43a22c9b4a7868a740e2de417f50702209d2aced.tar.bz2
samba-43a22c9b4a7868a740e2de417f50702209d2aced.zip
Add __repr__ implementation for Ldb.
(This used to be commit 5607aea07f66f09fd5b33842d07d2fbbf44d13e7)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/ldb.i6
-rw-r--r--source4/lib/ldb/ldb.py2
-rw-r--r--source4/lib/ldb/ldb_wrap.c32
-rwxr-xr-xsource4/lib/ldb/tests/python/api.py4
4 files changed, 43 insertions, 1 deletions
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
index 75482011fb..18e981f7be 100644
--- a/source4/lib/ldb/ldb.i
+++ b/source4/lib/ldb/ldb.i
@@ -781,6 +781,12 @@ typedef struct ldb_context {
return PyObject_GetIter(list);
}
+ char *__repr__(void)
+ {
+ char *ret;
+ asprintf(&ret, "<ldb connection at 0x%x>", ret);
+ return ret;
+ }
#endif
}
%pythoncode {
diff --git a/source4/lib/ldb/ldb.py b/source4/lib/ldb/ldb.py
index 60644d352c..e9f4055fbf 100644
--- a/source4/lib/ldb/ldb.py
+++ b/source4/lib/ldb/ldb.py
@@ -215,7 +215,6 @@ LDB_ERR_AFFECTS_MULTIPLE_DSAS = _ldb.LDB_ERR_AFFECTS_MULTIPLE_DSAS
LDB_ERR_OTHER = _ldb.LDB_ERR_OTHER
class Ldb(object):
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
- __repr__ = _swig_repr
def __init__(self, *args, **kwargs):
_ldb.Ldb_swiginit(self,_ldb.new_Ldb(*args, **kwargs))
__swig_destroy__ = _ldb.delete_Ldb
@@ -260,6 +259,7 @@ Ldb.schema_attribute_add = new_instancemethod(_ldb.Ldb_schema_attribute_add,None
Ldb.setup_wellknown_attributes = new_instancemethod(_ldb.Ldb_setup_wellknown_attributes,None,Ldb)
Ldb.__contains__ = new_instancemethod(_ldb.Ldb___contains__,None,Ldb)
Ldb.parse_ldif = new_instancemethod(_ldb.Ldb_parse_ldif,None,Ldb)
+Ldb.__repr__ = new_instancemethod(_ldb.Ldb___repr__,None,Ldb)
Ldb_swigregister = _ldb.Ldb_swigregister
Ldb_swigregister(Ldb)
diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c
index f13ed4dc3b..d787266416 100644
--- a/source4/lib/ldb/ldb_wrap.c
+++ b/source4/lib/ldb/ldb_wrap.c
@@ -3200,6 +3200,11 @@ SWIGINTERN PyObject *ldb_parse_ldif(ldb *self,char const *s){
}
return PyObject_GetIter(list);
}
+SWIGINTERN char *ldb___repr__(ldb *self){
+ char *ret;
+ asprintf(&ret, "<ldb connection at 0x%x>", ret);
+ return ret;
+ }
static char *timestring(time_t t)
{
@@ -5573,6 +5578,32 @@ fail:
}
+SWIGINTERN PyObject *_wrap_Ldb___repr__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb *arg1 = (ldb *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb___repr__" "', argument " "1"" of type '" "ldb *""'");
+ }
+ arg1 = (ldb *)(argp1);
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
+ result = (char *)ldb___repr__(arg1);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *Ldb_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
@@ -5762,6 +5793,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"Ldb_setup_wellknown_attributes", (PyCFunction)_wrap_Ldb_setup_wellknown_attributes, METH_O, NULL},
{ (char *)"Ldb___contains__", (PyCFunction) _wrap_Ldb___contains__, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Ldb_parse_ldif", (PyCFunction) _wrap_Ldb_parse_ldif, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Ldb___repr__", (PyCFunction)_wrap_Ldb___repr__, METH_O, NULL},
{ (char *)"Ldb_swigregister", Ldb_swigregister, METH_VARARGS, NULL},
{ (char *)"Ldb_swiginit", Ldb_swiginit, METH_VARARGS, NULL},
{ (char *)"valid_attr_name", (PyCFunction) _wrap_valid_attr_name, METH_VARARGS | METH_KEYWORDS, NULL},
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index 6f073f79a8..1ae3fde744 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -36,6 +36,10 @@ class SimpleLdb(unittest.TestCase):
x = ldb.Ldb()
x.connect("foo.tdb")
+ def test_repr(self):
+ x = ldb.Ldb()
+ self.assertTrue(repr(x).startswith("<ldb connection"))
+
def test_set_create_perms(self):
x = ldb.Ldb()
x.set_create_perms(0600)