1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

pyldb: add pyldb_check_type()

This will be used by pyldb_Ldb_AsLdbContext().

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
This commit is contained in:
Douglas Bagnall 2018-05-03 12:10:21 +12:00 committed by Douglas Bagnall
parent 19a13cbe06
commit f5e0339a0d
2 changed files with 13 additions and 0 deletions

View File

@ -46,6 +46,8 @@ PyObject *pyldb_Dn_FromDn(struct ldb_dn *);
bool pyldb_Object_AsDn(TALLOC_CTX *mem_ctx, PyObject *object, struct ldb_context *ldb_ctx, struct ldb_dn **dn);
#define pyldb_Dn_AsDn(pyobj) ((PyLdbDnObject *)pyobj)->dn
bool pyldb_check_type(PyObject *obj, const char *type_name);
typedef struct {
PyObject_HEAD
TALLOC_CTX *mem_ctx;

View File

@ -48,6 +48,17 @@ static PyTypeObject * PyLdb_GetPyType(const char *typename)
return (PyTypeObject*)py_obj;
}
bool pyldb_check_type(PyObject *obj, const char *typename)
{
bool ok = false;
PyTypeObject *type = PyLdb_GetPyType(typename);
if (type != NULL) {
ok = PyObject_TypeCheck(obj, type);
Py_DECREF(type);
}
return ok;
}
/**
* Obtain a ldb DN from a Python object.
*