1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-28 07:21:54 +03:00

pytdb: Add support for tdb_transaction_prepare_commit()

Cc: 597386@bugs.debian.org
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>

(This used to be ctdb commit fd16bcc1434841d84fdf78f80163c97c0b52b3fe)
This commit is contained in:
Kirill Smelkov 2010-09-19 13:53:32 +04:00 committed by Rusty Russell
parent 7b88df14e0
commit f1a720f08f
2 changed files with 18 additions and 0 deletions

View File

@ -112,6 +112,13 @@ static PyObject *obj_transaction_commit(PyTdbObject *self)
Py_RETURN_NONE;
}
static PyObject *obj_transaction_prepare_commit(PyTdbObject *self)
{
int ret = tdb_transaction_prepare_commit(self->ctx);
PyErr_TDB_ERROR_IS_ERR_RAISE(ret, self->ctx);
Py_RETURN_NONE;
}
static PyObject *obj_transaction_start(PyTdbObject *self)
{
int ret = tdb_transaction_start(self->ctx);
@ -351,6 +358,9 @@ static PyMethodDef tdb_object_methods[] = {
{ "transaction_commit", (PyCFunction)obj_transaction_commit, METH_NOARGS,
"S.transaction_commit() -> None\n"
"Commit the currently active transaction." },
{ "transaction_prepare_commit", (PyCFunction)obj_transaction_prepare_commit, METH_NOARGS,
"S.transaction_prepare_commit() -> None\n"
"Prepare to commit the currently active transaction" },
{ "transaction_start", (PyCFunction)obj_transaction_start, METH_NOARGS,
"S.transaction_start() -> None\n"
"Start a new transaction." },

View File

@ -111,6 +111,14 @@ class SimpleTdbTests(TestCase):
self.tdb.transaction_commit()
self.assertEquals("1", self.tdb["bloe"])
def test_transaction_prepare_commit(self):
self.tdb["bloe"] = "2"
self.tdb.transaction_start()
self.tdb["bloe"] = "1"
self.tdb.transaction_prepare_commit()
self.tdb.transaction_commit()
self.assertEquals("1", self.tdb["bloe"])
def test_iterator(self):
self.tdb["bloe"] = "2"
self.tdb["bla"] = "hoi"