summaryrefslogtreecommitdiff
path: root/lib/ldb/pyldb.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-07-14 13:17:49 +1000
committerAndrew Tridgell <tridge@samba.org>2011-07-21 11:44:36 +1000
commita36af1a5011dddd5551c768f9bf69188c8775a43 (patch)
tree7c9a445d7a2272d02f4be9c549d104ac3ac0e7b2 /lib/ldb/pyldb.c
parent9117a2fa3c5f6b6d16aefc9652670a2b5e878e7c (diff)
downloadsamba-a36af1a5011dddd5551c768f9bf69188c8775a43.tar.gz
samba-a36af1a5011dddd5551c768f9bf69188c8775a43.tar.bz2
samba-a36af1a5011dddd5551c768f9bf69188c8775a43.zip
pyldb: use dn.is_child_of() instead of dn.compare_base()
the compare_base() C API doesn't really fit well in python, as it returns 0 for true. Better to have a boolean function for the python interface. Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib/ldb/pyldb.c')
-rw-r--r--lib/ldb/pyldb.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c
index 4c71569f05..adec424aa1 100644
--- a/lib/ldb/pyldb.c
+++ b/lib/ldb/pyldb.c
@@ -522,7 +522,7 @@ static PyObject *py_ldb_dn_add_base(PyLdbDnObject *self, PyObject *args)
return ldb_dn_add_base(dn, other)?Py_True:Py_False;
}
-static PyObject *py_ldb_dn_compare_base(PyLdbDnObject *self, PyObject *args)
+static PyObject *py_ldb_dn_is_child_of(PyLdbDnObject *self, PyObject *args)
{
PyObject *py_base;
struct ldb_dn *dn, *base;
@@ -534,7 +534,7 @@ static PyObject *py_ldb_dn_compare_base(PyLdbDnObject *self, PyObject *args)
if (!PyObject_AsDn(NULL, py_base, dn_ldb_ctx(dn), &base))
return NULL;
- return PyInt_FromLong(ldb_dn_compare_base(base, dn));
+ return PyBool_FromLong(ldb_dn_compare_base(base, dn) == 0);
}
static PyMethodDef py_ldb_dn_methods[] = {
@@ -555,8 +555,8 @@ static PyMethodDef py_ldb_dn_methods[] = {
{ "canonical_str", (PyCFunction)py_ldb_dn_canonical_str, METH_NOARGS,
"S.canonical_str() -> string\n"
"Canonical version of this DN (like a posix path)." },
- { "compare_base", (PyCFunction)py_ldb_dn_compare_base, METH_VARARGS,
- "S.compare_base(basedn) -> int\n\n"},
+ { "is_child_of", (PyCFunction)py_ldb_dn_is_child_of, METH_VARARGS,
+ "S.is_child_of(basedn) -> int\nReturns True if this DN is a child of basedn\n"},
{ "canonical_ex_str", (PyCFunction)py_ldb_dn_canonical_ex_str, METH_NOARGS,
"S.canonical_ex_str() -> string\n"
"Canonical version of this DN (like a posix path, with terminating newline)." },