summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKirill Smelkov <kirr@landau.phys.spbu.ru>2010-09-19 13:53:32 +0400
committerJelmer Vernooij <jelmer@samba.org>2010-09-19 09:35:43 -0700
commitb3314d6ad8de732f563f095ea538c7b95c667d73 (patch)
tree6cb6bb3abc404727e8c1f4bfa1d371945eb1cf27 /lib
parentb826ef9697c4bd236b6d861712fa1e450157bc6f (diff)
downloadsamba-b3314d6ad8de732f563f095ea538c7b95c667d73.tar.gz
samba-b3314d6ad8de732f563f095ea538c7b95c667d73.tar.bz2
samba-b3314d6ad8de732f563f095ea538c7b95c667d73.zip
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/tdb/pytdb.c10
-rw-r--r--lib/tdb/python/tests/simple.py8
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index 303c7ffd89..e20c79aa8f 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -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." },
diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py
index abc888c4ed..9ef6d2927b 100644
--- a/lib/tdb/python/tests/simple.py
+++ b/lib/tdb/python/tests/simple.py
@@ -116,6 +116,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"