Commit 827f143e authored by Paul Selkirk's avatar Paul Selkirk
Browse files

[2908] remove ZoneTableIterator_getCurrent/isc.datasrc.get_current

parent db63f2e0
......@@ -175,7 +175,7 @@ class ClientListTest(unittest.TestCase):
self.assertIsNotNone(table)
iterator = table.get_iterator()
self.assertIsNotNone(iterator)
self.assertRaises(isc.datasrc.Error, iterator.get_current)
self.assertEqual(0, len(list(iterator)))
# normal configuration
self.clist.configure('''[{
......@@ -196,16 +196,14 @@ class ClientListTest(unittest.TestCase):
self.assertIsNotNone(table)
iterator = table.get_iterator()
self.assertIsNotNone(iterator)
index, origin = iterator.get_current()
self.assertEqual(origin.to_text(), "example.org.")
self.assertEqual(1, len(list(iterator)))
zonelist = list(iterator)
self.assertEqual(1, len(zonelist))
self.assertEqual(zonelist[0][1], isc.dns.Name("example.org"))
# named datasrc
table = self.clist.get_zone_table_accessor("MasterFiles", True)
iterator = table.get_iterator()
index, origin = iterator.get_current()
self.assertEqual(origin.to_text(), "example.org.")
self.assertEqual(1, len(list(iterator)))
self.assertEqual(zonelist, list(iterator))
# longer zone list for non-trivial iteration
self.clist.configure('''[{
......
......@@ -72,26 +72,6 @@ ZoneTableIterator_destroy(s_ZoneTableIterator* const self) {
// We declare the functions here, the definitions are below
// the type definition of the object, since both can use the other
//
PyObject*
ZoneTableIterator_getCurrent(PyObject* po_self, PyObject*) {
s_ZoneTableIterator* self = static_cast<s_ZoneTableIterator*>(po_self);
try {
const isc::datasrc::ZoneSpec& zs = self->cppobj->getCurrent();
return (Py_BuildValue("iO", zs.index,
isc::dns::python::createNameObject(zs.origin)));
} catch (const std::exception& ex) {
// isc::InvalidOperation is thrown when we call getCurrent()
// when we are already done iterating ('iterating past end')
// We could also simply return None again
PyErr_SetString(getDataSourceException("Error"), ex.what());
return (NULL);
} catch (...) {
PyErr_SetString(getDataSourceException("Error"),
"Unexpected exception");
return (NULL);
}
}
PyObject*
ZoneTableIterator_iter(PyObject *self) {
Py_INCREF(self);
......@@ -105,10 +85,16 @@ ZoneTableIterator_next(PyObject* po_self) {
return (NULL);
}
try {
PyObject* result = ZoneTableIterator_getCurrent(po_self, NULL);
const isc::datasrc::ZoneSpec& zs = self->cppobj->getCurrent();
PyObject* result =
Py_BuildValue("iO", zs.index,
isc::dns::python::createNameObject(zs.origin));
self->cppobj->next();
return (result);
} catch (const std::exception& exc) {
// isc::InvalidOperation is thrown when we call getCurrent()
// when we are already done iterating ('iterating past end')
// We could also simply return None again
PyErr_SetString(getDataSourceException("Error"), exc.what());
return (NULL);
} catch (...) {
......@@ -119,14 +105,6 @@ ZoneTableIterator_next(PyObject* po_self) {
}
PyMethodDef ZoneTableIterator_methods[] = {
{ "get_current", ZoneTableIterator_getCurrent, METH_NOARGS,
"get_current() -> isc.datasrc.ZoneSpec\n\
\n\
Return the information of the zone at which the iterator is\
currently located\n\
\n\
This method must not be called once the iterator reaches the end\
of the zone table.\n" },
{ NULL, NULL, 0, NULL }
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment