diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2010-06-19 17:09:52 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2010-06-19 22:46:43 +0200 |
commit | a4f60ffe4bb4e0e32d7cd62dc872b1f23435edca (patch) | |
tree | e8d23b2dbb40e1e40200cc2e928443b8746d842d /source4/scripting | |
parent | 05b108a06b383f2172a379629b9a6bcff82c6868 (diff) | |
download | samba-a4f60ffe4bb4e0e32d7cd62dc872b1f23435edca.tar.gz samba-a4f60ffe4bb4e0e32d7cd62dc872b1f23435edca.tar.bz2 samba-a4f60ffe4bb4e0e32d7cd62dc872b1f23435edca.zip |
pydsdb: Move dsdb_set_schema_from_ldb to pydsdb.
Diffstat (limited to 'source4/scripting')
-rw-r--r-- | source4/scripting/python/pyglue.c | 48 | ||||
-rw-r--r-- | source4/scripting/python/samba/__init__.py | 2 |
2 files changed, 1 insertions, 49 deletions
diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c index 8dc80505d6..ce164a7085 100644 --- a/source4/scripting/python/pyglue.c +++ b/source4/scripting/python/pyglue.c @@ -46,25 +46,6 @@ } */\ ldb = PyLdb_AsLdbContext(py_ldb); -static void PyErr_SetLdbError(PyObject *error, int ret, struct ldb_context *ldb_ctx) -{ - if (ret == LDB_ERR_PYTHON_EXCEPTION) - return; /* Python exception should already be set, just keep that */ - - PyErr_SetObject(error, - Py_BuildValue(discard_const_p(char, "(i,s)"), ret, - ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx))); -} - -static PyObject *py_ldb_get_exception(void) -{ - PyObject *mod = PyImport_ImportModule("ldb"); - if (mod == NULL) - return NULL; - - return PyObject_GetAttrString(mod, "LdbError"); -} - static PyObject *py_generate_random_str(PyObject *self, PyObject *args) { int len; @@ -174,33 +155,6 @@ static PyObject *py_dsdb_write_prefixes_from_schema_to_ldb(PyObject *self, PyObj Py_RETURN_NONE; } -static PyObject *py_dsdb_set_schema_from_ldb(PyObject *self, PyObject *args) -{ - PyObject *py_ldb; - struct ldb_context *ldb; - PyObject *py_from_ldb; - struct ldb_context *from_ldb; - struct dsdb_schema *schema; - int ret; - if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_from_ldb)) - return NULL; - - PyErr_LDB_OR_RAISE(py_ldb, ldb); - - PyErr_LDB_OR_RAISE(py_from_ldb, from_ldb); - - schema = dsdb_get_schema(from_ldb, NULL); - if (!schema) { - PyErr_SetString(PyExc_RuntimeError, "Failed to set find a schema on 'from' ldb!\n"); - return NULL; - } - - ret = dsdb_reference_schema(ldb, schema, true); - PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb); - - Py_RETURN_NONE; -} - /* return the list of interface IPs we have configured takes an loadparm context, returns a list of IPs in string form @@ -270,8 +224,6 @@ static PyMethodDef py_misc_methods[] = { "nttime2string(nttime) -> string" }, { "dsdb_write_prefixes_from_schema_to_ldb", (PyCFunction)py_dsdb_write_prefixes_from_schema_to_ldb, METH_VARARGS, NULL }, - { "dsdb_set_schema_from_ldb", (PyCFunction)py_dsdb_set_schema_from_ldb, METH_VARARGS, - NULL }, { "set_debug_level", (PyCFunction)py_set_debug_level, METH_VARARGS, "set debug level" }, { "interface_ips", (PyCFunction)py_interface_ips, METH_VARARGS, diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py index d03cdc13a5..2f125e6ba7 100644 --- a/source4/scripting/python/samba/__init__.py +++ b/source4/scripting/python/samba/__init__.py @@ -284,7 +284,7 @@ class Ldb(_Ldb): return dsdb.dsdb_get_oid_from_attid(self, attid) def set_schema_from_ldb(self, ldb): - _glue.dsdb_set_schema_from_ldb(self, ldb) + dsdb.dsdb_set_schema_from_ldb(self, ldb) def write_prefixes_from_schema(self): _glue.dsdb_write_prefixes_from_schema_to_ldb(self) |