diff options
author | John Mulligan <jmulligan@redhat.com> | 2022-04-25 12:04:20 -0400 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2022-05-06 18:14:30 +0000 |
commit | f9df57043e487d951e371367ebe41e1ed0124959 (patch) | |
tree | 0d27f57be48de57e829935b1b60fad6c3b6ef386 /lib/smbconf | |
parent | cc26fe829cb576f7ed5371d157da3fe5e165597b (diff) | |
download | samba-f9df57043e487d951e371367ebe41e1ed0124959.tar.gz |
lib/smbconf: add python wrapper functions for transaction management
The smbconf API supports transactions. This changes adds wrapper
functions transaction_start, transaction_commit, and transaction_cancel.
It also adds tests for the functions, one of which demonstrates a
semi-pythonic way to use said functions.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri May 6 18:14:30 UTC 2022 on sn-devel-184
Diffstat (limited to 'lib/smbconf')
-rw-r--r-- | lib/smbconf/pysmbconf.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/smbconf/pysmbconf.c b/lib/smbconf/pysmbconf.c index 6edca974ccd..b0aca4508af 100644 --- a/lib/smbconf/pysmbconf.c +++ b/lib/smbconf/pysmbconf.c @@ -518,6 +518,39 @@ static PyObject *obj_delete_global_parameter(py_SMBConf_Object * self, Py_RETURN_NONE; } +static PyObject *obj_transaction_start(py_SMBConf_Object * self, + PyObject * Py_UNUSED(ignored)) +{ + sbcErr err = smbconf_transaction_start(self->conf_ctx); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject *obj_transaction_commit(py_SMBConf_Object * self, + PyObject * Py_UNUSED(ignored)) +{ + sbcErr err = smbconf_transaction_commit(self->conf_ctx); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject *obj_transaction_cancel(py_SMBConf_Object * self, + PyObject * Py_UNUSED(ignored)) +{ + sbcErr err = smbconf_transaction_cancel(self->conf_ctx); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + return NULL; + } + Py_RETURN_NONE; +} + PyDoc_STRVAR(obj_requires_messaging_doc, "requires_messaging() -> bool\n" "\n" @@ -583,6 +616,19 @@ PyDoc_STRVAR(obj_delete_global_parameter_doc, "delete_parameter(str, str) -> None\n" "Delete a single global configuration parameter.\n"); +PyDoc_STRVAR(obj_transaction_start_doc, +"transaction_start() -> None\n" +"Start a transaction.\n" +"Transactions allow making compound sets of changes atomically.\n"); + +PyDoc_STRVAR(obj_transaction_commit_doc, +"transaction_commit() -> None\n" +"Commit the transaction.\n"); + +PyDoc_STRVAR(obj_transaction_cancel_doc, +"transaction_cancel() -> None\n" +"Cancel the transaction.\n"); + static PyMethodDef py_smbconf_obj_methods[] = { { "requires_messaging", (PyCFunction) obj_requires_messaging, METH_NOARGS, obj_requires_messaging_doc }, @@ -610,6 +656,12 @@ static PyMethodDef py_smbconf_obj_methods[] = { obj_delete_parameter_doc }, { "delete_global_parameter", (PyCFunction) obj_delete_global_parameter, METH_VARARGS, obj_delete_global_parameter_doc }, + { "transaction_start", (PyCFunction) obj_transaction_start, METH_NOARGS, + obj_transaction_start_doc }, + { "transaction_commit", (PyCFunction) obj_transaction_commit, + METH_NOARGS, obj_transaction_commit_doc }, + { "transaction_cancel", (PyCFunction) obj_transaction_cancel, + METH_NOARGS, obj_transaction_cancel_doc }, { 0 }, }; |