Cc: [email protected]
Signed-off-by: Kirill Smelkov <[email protected]>
---
 lib/tdb/pytdb.c                |   23 +++++++++++++++++++++++
 lib/tdb/python/tests/simple.py |    8 ++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index 706e868..25aefb0 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -426,6 +426,18 @@ static PyObject *obj_printfreelist(PyTdbObject *self)
        Py_RETURN_NONE;
 }
 
+static PyObject *obj_enable_seqnum(PyTdbObject *self)
+{
+       tdb_enable_seqnum(self->ctx);
+       Py_RETURN_NONE;
+}
+
+static PyObject *obj_increment_seqnum_nonblock(PyTdbObject *self)
+{
+       tdb_increment_seqnum_nonblock(self->ctx);
+       Py_RETURN_NONE;
+}
+
 static PyMethodDef tdb_object_methods[] = {
        { "transaction_cancel", (PyCFunction)obj_transaction_cancel, 
METH_NOARGS, 
                "S.transaction_cancel() -> None\n"
@@ -480,6 +492,10 @@ static PyMethodDef tdb_object_methods[] = {
        { "dump_all", (PyCFunction)obj_dump_all, METH_NOARGS, "S.dump_all() -> 
None" },
        { "printfreelist", (PyCFunction)obj_printfreelist, METH_NOARGS,
                "S.print_freelist -> None" },
+       { "enable_seqnum", (PyCFunction)obj_enable_seqnum, METH_NOARGS,
+               "S.enable_seqnum() -> None" },
+       { "increment_seqnum_nonblock", 
(PyCFunction)obj_increment_seqnum_nonblock, METH_NOARGS,
+               "S.increment_seqnum_nonblock() -> None" },
        { NULL }
 };
 
@@ -511,12 +527,19 @@ static PyObject *obj_get_filename(PyTdbObject *self, void 
*closure)
        return PyString_FromString(tdb_name(self->ctx));
 }
 
+static PyObject *obj_get_seqnum(PyTdbObject *self, void *closure)
+{
+       return PyInt_FromLong(tdb_get_seqnum(self->ctx));
+}
+
+
 static PyGetSetDef tdb_object_getsetters[] = {
        { (char *)"hash_size", (getter)obj_get_hash_size, NULL, NULL },
        { (char *)"map_size", (getter)obj_get_map_size, NULL, NULL },
        { (char *)"flags", (getter)obj_get_flags, NULL, NULL },
        { (char *)"max_dead", NULL, (setter)obj_set_max_dead, NULL },
        { (char *)"filename", (getter)obj_get_filename, NULL, (char *)"The 
filename of this TDB file."},
+       { (char *)"seqnum", (getter)obj_get_seqnum, NULL, NULL },
        { NULL }
 };
 
diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py
index 0dfa9d0..c47c9e0 100644
--- a/lib/tdb/python/tests/simple.py
+++ b/lib/tdb/python/tests/simple.py
@@ -170,6 +170,14 @@ class SimpleTdbTests(TestCase):
         self.tdb.dump_all()
         self.tdb.printfreelist()
 
+    def test_seqnum(self):
+        self.tdb.enable_seqnum()
+        seq1 = self.tdb.seqnum
+        self.tdb.increment_seqnum_nonblock()
+        seq2 = self.tdb.seqnum
+        self.assertEquals(seq2-seq1, 1)
+
+
     def test_len(self):
         self.assertEquals(0, len(list(self.tdb)))
         self.tdb["entry"] = "value"
-- 
1.7.3.rc2



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to