BIND 10 trac1179, updated. f1fef139dbc592aa4c7071d47e38e14487ab72e7 [1179] small comment addition

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Sep 23 15:10:20 UTC 2011


The branch, trac1179 has been updated
       via  f1fef139dbc592aa4c7071d47e38e14487ab72e7 (commit)
       via  2c8b76ed408547789f2e26ad76773e40e316a392 (commit)
       via  eefa62a767ec09c20d679876842e15e9d3742499 (commit)
       via  58845974d57ee0cd0b261b00d1ededccc7bde105 (commit)
       via  d49e3c5e79e00b59e518c4bc1f71882adf721696 (commit)
      from  9b4326dc093b71bcd77a527111ea6778795bf068 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f1fef139dbc592aa4c7071d47e38e14487ab72e7
Author: Jelte Jansen <jelte at isc.org>
Date:   Fri Sep 23 17:10:05 2011 +0200

    [1179] small comment addition

commit 2c8b76ed408547789f2e26ad76773e40e316a392
Author: Jelte Jansen <jelte at isc.org>
Date:   Fri Sep 23 16:53:37 2011 +0200

    [1179] remove some unneceesary comments, and share find() code

commit eefa62a767ec09c20d679876842e15e9d3742499
Author: Jelte Jansen <jelte at isc.org>
Date:   Fri Sep 23 16:01:41 2011 +0200

    [1179] make that datasrc_libdir

commit 58845974d57ee0cd0b261b00d1ededccc7bde105
Author: Jelte Jansen <jelte at isc.org>
Date:   Fri Sep 23 16:00:58 2011 +0200

    [1179] update variable name in __init__.py

commit d49e3c5e79e00b59e518c4bc1f71882adf721696
Author: Jelte Jansen <jelte at isc.org>
Date:   Fri Sep 23 15:57:32 2011 +0200

    [1179] different way to test all output from get_iterator()

-----------------------------------------------------------------------

Summary of changes:
 src/lib/python/isc/datasrc/__init__.py           |    6 +-
 src/lib/python/isc/datasrc/client_python.cc      |    9 -
 src/lib/python/isc/datasrc/datasrc.cc            |   10 +-
 src/lib/python/isc/datasrc/datasrc.h             |    2 +-
 src/lib/python/isc/datasrc/finder_python.cc      |   97 ++++++----
 src/lib/python/isc/datasrc/iterator_python.cc    |    2 -
 src/lib/python/isc/datasrc/tests/datasrc_test.py |  224 ++++++++++++----------
 src/lib/python/isc/datasrc/updater_python.cc     |   18 ++-
 8 files changed, 198 insertions(+), 170 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/datasrc/__init__.py b/src/lib/python/isc/datasrc/__init__.py
index e78103a..05911f7 100644
--- a/src/lib/python/isc/datasrc/__init__.py
+++ b/src/lib/python/isc/datasrc/__init__.py
@@ -2,8 +2,8 @@ from isc.datasrc.master import *
 from isc.datasrc.sqlite3_ds import *
 
 for base in sys.path[:]:
-    loglibdir = os.path.join(base, 'isc/datasrc/.libs')
-    if os.path.exists(loglibdir):
-        sys.path.insert(0, loglibdir)
+    datasrc_libdir = os.path.join(base, 'isc/datasrc/.libs')
+    if os.path.exists(datasrc_libdir):
+        sys.path.insert(0, datasrc_libdir)
 
 from datasrc import *
diff --git a/src/lib/python/isc/datasrc/client_python.cc b/src/lib/python/isc/datasrc/client_python.cc
index e6f1872..984eabf 100644
--- a/src/lib/python/isc/datasrc/client_python.cc
+++ b/src/lib/python/isc/datasrc/client_python.cc
@@ -57,8 +57,6 @@ public:
 typedef CPPPyObjectContainer<s_DataSourceClient, DataSourceClient>
     DataSourceClientContainer;
 
-// These are the functions we export
-//
 PyObject*
 DataSourceClient_findZone(PyObject* po_self, PyObject* args) {
     s_DataSourceClient* const self = static_cast<s_DataSourceClient*>(po_self);
@@ -145,8 +143,6 @@ DataSourceClient_getUpdater(PyObject* po_self, PyObject* args) {
     }
 }
 
-// These are the functions we export
-
 // This list contains the actual set of functions we have in
 // python. Each entry has
 // 1. Python method name
@@ -164,9 +160,6 @@ PyMethodDef DataSourceClient_methods[] = {
     { NULL, NULL, 0, NULL }
 };
 
-// This is a template of typical code logic of python class initialization
-// with C++ backend.  You'll need to adjust it according to details of the
-// actual C++ class.
 int
 DataSourceClient_init(s_DataSourceClient* self, PyObject* args) {
     // TODO: we should use the factory function which hasn't been written
@@ -201,8 +194,6 @@ DataSourceClient_init(s_DataSourceClient* self, PyObject* args) {
     return (-1);
 }
 
-// This is a template of typical code logic of python object destructor.
-// In many cases you can use it without modification, but check that carefully.
 void
 DataSourceClient_destroy(s_DataSourceClient* const self) {
     delete self->cppobj;
diff --git a/src/lib/python/isc/datasrc/datasrc.cc b/src/lib/python/isc/datasrc/datasrc.cc
index f0e65d2..4b0324a 100644
--- a/src/lib/python/isc/datasrc/datasrc.cc
+++ b/src/lib/python/isc/datasrc/datasrc.cc
@@ -43,11 +43,11 @@ PyObject*
 getDataSourceException(const char* ex_name) {
     PyObject* ex_obj = NULL;
 
-    PyObject* acl_module = PyImport_AddModule("isc.datasrc");
-    if (acl_module != NULL) {
-        PyObject* acl_dict = PyModule_GetDict(acl_module);
-        if (acl_dict != NULL) {
-            ex_obj = PyDict_GetItemString(acl_dict, ex_name);
+    PyObject* datasrc_module = PyImport_AddModule("isc.datasrc");
+    if (datasrc_module != NULL) {
+        PyObject* datasrc_dict = PyModule_GetDict(datasrc_module);
+        if (datasrc_dict != NULL) {
+            ex_obj = PyDict_GetItemString(datasrc_dict, ex_name);
         }
     }
 
diff --git a/src/lib/python/isc/datasrc/datasrc.h b/src/lib/python/isc/datasrc/datasrc.h
index 9ad1212..d82881b 100644
--- a/src/lib/python/isc/datasrc/datasrc.h
+++ b/src/lib/python/isc/datasrc/datasrc.h
@@ -29,7 +29,7 @@ namespace python {
 // C/C++ symbols defined in that module.  So we get access to these object
 // using the Python interpretor through this wrapper function.
 //
-// The __init__.py file should ensure isc.acl.acl has been loaded by the time
+// The __init__.py file should ensure isc.datasrc has been loaded by the time
 // whenever this function is called, and there shouldn't be any operation
 // within this function that can fail (such as dynamic memory allocation),
 // so this function should always succeed.  Yet there may be an overlooked
diff --git a/src/lib/python/isc/datasrc/finder_python.cc b/src/lib/python/isc/datasrc/finder_python.cc
index b1f9711..598d300 100644
--- a/src/lib/python/isc/datasrc/finder_python.cc
+++ b/src/lib/python/isc/datasrc/finder_python.cc
@@ -45,6 +45,60 @@ using namespace isc::dns::python;
 using namespace isc::datasrc;
 using namespace isc::datasrc::python;
 
+namespace isc_datasrc_internal {
+// This is the shared code for the find() call in the finder and the updater
+// Is is intentionally not available through any header, nor at our standard
+// namespace, as it is not supposed to be called anywhere but from finder and
+// updater
+PyObject* ZoneFinder_helper(ZoneFinder* finder, PyObject* args) {
+    if (finder == NULL) {
+        PyErr_SetString(getDataSourceException("Error"),
+                        "Internal error in find() wrapper; finder object NULL");
+        return (NULL);
+    }
+    PyObject *name;
+    PyObject *rrtype;
+    PyObject *target;
+    int options_int;
+    if (PyArg_ParseTuple(args, "O!O!OI", &name_type, &name,
+                                         &rrtype_type, &rrtype,
+                                         &target, &options_int)) {
+        try {
+            ZoneFinder::FindOptions options =
+                static_cast<ZoneFinder::FindOptions>(options_int);
+            ZoneFinder::FindResult find_result(
+                finder->find(PyName_ToName(name),
+                                   PyRRType_ToRRType(rrtype),
+                                   NULL,
+                                   options
+                                   ));
+            ZoneFinder::Result r = find_result.code;
+            isc::dns::ConstRRsetPtr rrsp = find_result.rrset;
+            if (rrsp) {
+                // Use N instead of O so the refcount isn't increased twice
+                return (Py_BuildValue("IN", r, createRRsetObject(*rrsp)));
+            } else {
+                return (Py_BuildValue("IO", r, Py_None));
+            }
+        } catch (const DataSourceError& dse) {
+            PyErr_SetString(getDataSourceException("Error"), dse.what());
+            return (NULL);
+        } catch (const std::exception& exc) {
+            PyErr_SetString(getDataSourceException("Error"), exc.what());
+            return (NULL);
+        } catch (...) {
+            PyErr_SetString(getDataSourceException("Error"),
+                            "Unexpected exception");
+            return (NULL);
+        }
+    } else {
+        return (NULL);
+    }
+    return Py_BuildValue("I", 1);
+}
+
+} // end namespace internal
+
 namespace {
 // The s_* Class simply covers one instantiation of the object
 class s_ZoneFinder : public PyObject {
@@ -74,8 +128,6 @@ ZoneFinder_destroy(s_ZoneFinder* const self) {
     Py_TYPE(self)->tp_free(self);
 }
 
-// These are the functions we export
-//
 PyObject*
 ZoneFinder_getClass(PyObject* po_self, PyObject*) {
     s_ZoneFinder* self = static_cast<s_ZoneFinder*>(po_self);
@@ -105,45 +157,7 @@ ZoneFinder_getOrigin(PyObject* po_self, PyObject*) {
 PyObject*
 ZoneFinder_find(PyObject* po_self, PyObject* args) {
     s_ZoneFinder* const self = static_cast<s_ZoneFinder*>(po_self);
-    PyObject *name;
-    PyObject *rrtype;
-    PyObject *target;
-    int options_int;
-    if (PyArg_ParseTuple(args, "O!O!OI", &name_type, &name,
-                                         &rrtype_type, &rrtype,
-                                         &target, &options_int)) {
-        try {
-            ZoneFinder::FindOptions options =
-                static_cast<ZoneFinder::FindOptions>(options_int);
-            ZoneFinder::FindResult find_result(
-                self->cppobj->find(PyName_ToName(name),
-                                   PyRRType_ToRRType(rrtype),
-                                   NULL,
-                                   options
-                                   ));
-            ZoneFinder::Result r = find_result.code;
-            isc::dns::ConstRRsetPtr rrsp = find_result.rrset;
-            if (rrsp) {
-                // Use N instead of O so the refcount isn't increased twice
-                return (Py_BuildValue("IN", r, createRRsetObject(*rrsp)));
-            } else {
-                return (Py_BuildValue("IO", r, Py_None));
-            }
-        } catch (const DataSourceError& dse) {
-            PyErr_SetString(getDataSourceException("Error"), dse.what());
-            return (NULL);
-        } catch (const std::exception& exc) {
-            PyErr_SetString(getDataSourceException("Error"), exc.what());
-            return (NULL);
-        } catch (...) {
-            PyErr_SetString(getDataSourceException("Error"),
-                            "Unexpected exception");
-            return (NULL);
-        }
-    } else {
-        return (NULL);
-    }
-    return Py_BuildValue("I", 1);
+    return (isc_datasrc_internal::ZoneFinder_helper(self->cppobj.get(), args));
 }
 
 // This list contains the actual set of functions we have in
@@ -167,6 +181,7 @@ PyMethodDef ZoneFinder_methods[] = {
 namespace isc {
 namespace datasrc {
 namespace python {
+
 PyTypeObject zonefinder_type = {
     PyVarObject_HEAD_INIT(NULL, 0)
     "datasrc.ZoneFinder",
diff --git a/src/lib/python/isc/datasrc/iterator_python.cc b/src/lib/python/isc/datasrc/iterator_python.cc
index 1797bb4..b482ea6 100644
--- a/src/lib/python/isc/datasrc/iterator_python.cc
+++ b/src/lib/python/isc/datasrc/iterator_python.cc
@@ -63,8 +63,6 @@ ZoneIterator_init(s_ZoneIterator* self, PyObject* args) {
     return (-1);
 }
 
-// This is a template of typical code logic of python object destructor.
-// In many cases you can use it without modification, but check that carefully.
 void
 ZoneIterator_destroy(s_ZoneIterator* const self) {
     // cppobj is a shared ptr, but to make sure things are not destroyed in
diff --git a/src/lib/python/isc/datasrc/tests/datasrc_test.py b/src/lib/python/isc/datasrc/tests/datasrc_test.py
index 57f56b9..15ceb80 100644
--- a/src/lib/python/isc/datasrc/tests/datasrc_test.py
+++ b/src/lib/python/isc/datasrc/tests/datasrc_test.py
@@ -28,125 +28,143 @@ BROKEN_DB_FILE = TESTDATA_PATH + "brokendb.sqlite3"
 WRITE_ZONE_DB_FILE = TESTDATA_WRITE_PATH + "rwtest.sqlite3.copied"
 NEW_DB_FILE = TESTDATA_WRITE_PATH + "new_db.sqlite3"
 
+def add_rrset(rrset_list, name, rrclass, rrtype, ttl, rdatas):
+    rrset_to_add = isc.dns.RRset(name, rrclass, rrtype, ttl)
+    if rdatas is not None:
+        for rdata in rdatas:
+            rrset_to_add.add_rdata(isc.dns.Rdata(rrtype, rrclass, rdata))
+    rrset_list.append(rrset_to_add)
+
+# helper function, we have no direct rrset comparison atm
+def rrsets_equal(a, b):
+    # no accessor for sigs either (so this only checks name, class, type, ttl,
+    # and rdata)
+    # also, because of the fake data in rrsigs, if the type is rrsig, the
+    # rdata is not checked
+    return a.get_name() == b.get_name() and\
+           a.get_class() == b.get_class() and\
+           a.get_type() == b.get_type() and \
+           a.get_ttl() == b.get_ttl() and\
+           (a.get_type() == isc.dns.RRType.RRSIG() or
+            sorted(a.get_rdata()) == sorted(b.get_rdata()))
+
+# returns true if rrset is in expected_rrsets
+# will remove the rrset from expected_rrsets if found
+def check_for_rrset(expected_rrsets, rrset):
+    for cur_rrset in expected_rrsets[:]:
+        if rrsets_equal(cur_rrset, rrset):
+            expected_rrsets.remove(cur_rrset)
+            return True
+    return False
+
 class DataSrcClient(unittest.TestCase):
 
     def test_construct(self):
         # can't construct directly
         self.assertRaises(TypeError, isc.datasrc.ZoneIterator)
 
+
     def test_iterate(self):
         dsc = isc.datasrc.DataSourceClient(READ_ZONE_DB_FILE)
 
         # for RRSIGS, the TTL's are currently modified. This test should
         # start failing when we fix that.
         rrs = dsc.get_iterator(isc.dns.Name("sql1.example.com."))
-        self.assertEqual("sql1.example.com. 3600 IN DNSKEY 256 3 5 AwEAAdYdRh" +
-                         "BAEY67R/8G1N5AjGF6asIiNh/pNGeQ8xDQP13JN2lo+sNqWcmpY" +
-                         "NhuVqRbLB+mamsU1XcCICSBvAlSmfz/ZUdafX23knArTlALxMms" +
-                         "pcfdpqun3Yr3YYnztuj06rV7RqmveYckWvAUXVYMSMQZfJ305fs" +
-                         "0dE/xLztL/CzZ\nsql1.example.com. 3600 IN DNSKEY 257" +
-                         " 3 5 AwEAAbaKDSa9XEFTsjSYpUTHRotTS9Tz3krfDucugW5Uok" +
-                         "GQKC26QlyHXlPTZkC+aRFUs/dicJX2kopndLcnlNAPWiKnKtrsF" +
-                         "SCnIJDBZIyvcKq+9RXmV3HK3bUdHnQZ88IZWBRmWKfZ6wnzHo53" +
-                         "kdYKAemTErkztaX3lRRPLYWpxRcDPEjysXT3Lh0vfL5D+CIO1yK" +
-                         "w/q7C+v6+/kYAxc2lfbNE3HpklSuF+dyX4nXxWgzbcFuLz5Bwfq" +
-                         "6ZJ9RYe/kNkA0uMWNa1KkGeRh8gg22kgD/KT5hPTnpezUWLvoY5" +
-                         "Qc7IB3T0y4n2JIwiF2ZrZYVrWgDjRWAzGsxJiJyjd6w2k0=\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("sql1.example.com. 3600 IN NS dns01.example.com.\nsq" +
-                         "l1.example.com. 3600 IN NS dns02.example.com.\nsql1" +
-                         ".example.com. 3600 IN NS dns03.example.com.\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("sql1.example.com. 7200 IN NSEC www.sql1.example.com" +
-                         ". NS SOA RRSIG NSEC DNSKEY\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("sql1.example.com. 3600 IN RRSIG SOA 5 3 3600 201003" +
-                         "22084536 20100220084536 12447 sql1.example.com. FAK" +
-                         "EFAKEFAKEFAKE\nsql1.example.com. 3600 IN RRSIG NS 5" +
-                         " 3 3600 20100322084536 20100220084536 12447 sql1.ex" +
-                         "ample.com. FAKEFAKEFAKEFAKE\nsql1.example.com. 3600" +
-                         " IN RRSIG NSEC 5 3 7200 20100322084536 201002200845" +
-                         "36 12447 sql1.example.com. FAKEFAKEFAKEFAKE\nsql1.e" +
-                         "xample.com. 3600 IN RRSIG DNSKEY 5 3 3600 201003220" +
-                         "84536 20100220084536 12447 sql1.example.com. FAKEFA" +
-                         "KEFAKEFAKE\nsql1.example.com. 3600 IN RRSIG DNSKEY " +
-                         "5 3 3600 20100322084536 20100220084536 33313 sql1.e" +
-                         "xample.com. FAKEFAKEFAKEFAKE\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("sql1.example.com. 3600 IN SOA master.example.com. a" +
-                         "dmin.example.com. 678 3600 1800 2419200 7200\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("www.sql1.example.com. 3600 IN A 192.0.2.100\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("www.sql1.example.com. 7200 IN NSEC sql1.example.com" +
-                         ". A RRSIG NSEC\n", rrs.get_next_rrset().to_text())
-        self.assertEqual("www.sql1.example.com. 3600 IN RRSIG A 5 4 3600 2010" +
-                         "0322084536 20100220084536 12447 sql1.example.com. F" +
-                         "AKEFAKEFAKEFAKE\nwww.sql1.example.com. 3600 IN RRSI" +
-                         "G NSEC 5 4 7200 20100322084536 20100220084536 12447" +
-                         " sql1.example.com. FAKEFAKEFAKEFAKE\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual(None, rrs.get_next_rrset())
+
+        # we do not know the order in which they are returned by the iterator
+        # but we do want to check them, so we put all records into one list
+        # sort it (doesn't matter which way it is sorted, as long as it is
+        # sorted)
+
+        # RRset is (atm) an unorderable type, and within an rrset, the
+        # rdatas and rrsigs may also be in random order. In theory the
+        # rrsets themselves can be returned in any order.
+        #
+        # So we create a second list with all rrsets we expect, and for each
+        # rrset we get from the iterator, see if it is in that list, and
+        # remove it.
+        #
+        # When the iterator is empty, we check no rrsets are left in the
+        # list of expected ones
+        expected_rrset_list = []
+
+        name = isc.dns.Name("sql1.example.com")
+        rrclass = isc.dns.RRClass.IN()
+        add_rrset(expected_rrset_list, name, rrclass,
+                  isc.dns.RRType.DNSKEY(), isc.dns.RRTTL(3600),
+                  [
+                     "256 3 5 AwEAAdYdRhBAEY67R/8G1N5AjGF6asIiNh/pNGeQ8xDQP13J"+
+                     "N2lo+sNqWcmpYNhuVqRbLB+mamsU1XcCICSBvAlSmfz/ZUdafX23knAr"+
+                     "TlALxMmspcfdpqun3Yr3YYnztuj06rV7RqmveYckWvAUXVYMSMQZfJ30"+
+                     "5fs0dE/xLztL/CzZ",
+                     "257 3 5 AwEAAbaKDSa9XEFTsjSYpUTHRotTS9Tz3krfDucugW5UokGQ"+
+                     "KC26QlyHXlPTZkC+aRFUs/dicJX2kopndLcnlNAPWiKnKtrsFSCnIJDB"+
+                     "ZIyvcKq+9RXmV3HK3bUdHnQZ88IZWBRmWKfZ6wnzHo53kdYKAemTErkz"+
+                     "taX3lRRPLYWpxRcDPEjysXT3Lh0vfL5D+CIO1yKw/q7C+v6+/kYAxc2l"+
+                     "fbNE3HpklSuF+dyX4nXxWgzbcFuLz5Bwfq6ZJ9RYe/kNkA0uMWNa1KkG"+
+                     "eRh8gg22kgD/KT5hPTnpezUWLvoY5Qc7IB3T0y4n2JIwiF2ZrZYVrWgD"+
+                     "jRWAzGsxJiJyjd6w2k0="
+                  ])
+        add_rrset(expected_rrset_list, name, rrclass,
+                  isc.dns.RRType.NS(), isc.dns.RRTTL(3600),
+                  [
+                    "dns01.example.com.",
+                    "dns02.example.com.",
+                    "dns03.example.com."
+                  ])
+        add_rrset(expected_rrset_list, name, rrclass,
+                  isc.dns.RRType.NSEC(), isc.dns.RRTTL(7200),
+                  [
+                     "www.sql1.example.com. NS SOA RRSIG NSEC DNSKEY"
+                  ])
+        # For RRSIGS, we can't add the fake data through the API, so we
+        # simply pass no rdata at all (which is skipped by the check later)
+        add_rrset(expected_rrset_list, name, rrclass,
+                  isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
+        add_rrset(expected_rrset_list, name, rrclass,
+                  isc.dns.RRType.SOA(), isc.dns.RRTTL(3600),
+                  [
+                     "master.example.com. admin.example.com. 678 3600 1800 2419200 7200"
+                  ])
+        name = isc.dns.Name("www.sql1.example.com.")
+        add_rrset(expected_rrset_list, name, rrclass,
+                  isc.dns.RRType.A(), isc.dns.RRTTL(3600),
+                  [
+                     "192.0.2.100"
+                  ])
+        name = isc.dns.Name("www.sql1.example.com.")
+        add_rrset(expected_rrset_list, name, rrclass,
+                  isc.dns.RRType.NSEC(), isc.dns.RRTTL(7200),
+                  [
+                     "sql1.example.com. A RRSIG NSEC"
+                  ])
+        add_rrset(expected_rrset_list, name, rrclass,
+                  isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
+
+        # rrs is an iterator, but also has direct get_next_rrset(), use
+        # the latter one here
+        rrset_to_check = rrs.get_next_rrset()
+        while (rrset_to_check != None):
+            self.assertTrue(check_for_rrset(expected_rrset_list,
+                                            rrset_to_check),
+                            "Unexpected rrset returned by iterator:\n" +
+                            rrset_to_check.to_text())
+            rrset_to_check = rrs.get_next_rrset()
+
+        # Now check there are none left
+        self.assertEqual(0, len(expected_rrset_list),
+                         "RRset(s) not returned by iterator: " +
+                         str([rrset.to_text() for rrset in expected_rrset_list ]
+                        ))
+
         # TODO should we catch this (iterating past end) and just return None
         # instead of failing?
         self.assertRaises(isc.datasrc.Error, rrs.get_next_rrset)
 
-        rrs = dsc.get_iterator(isc.dns.Name("example.com"))
-        self.assertEqual("*.wild.example.com. 3600 IN A 192.0.2.255\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("*.wild.example.com. 7200 IN NSEC www.example.com. A" +
-                         " RRSIG NSEC\n", rrs.get_next_rrset().to_text())
-        self.assertEqual("*.wild.example.com. 3600 IN RRSIG A 5 3 3600 201003" +
-                         "22084538 20100220084538 33495 example.com. FAKEFAKE" +
-                         "FAKEFAKE\n*.wild.example.com. 3600 IN RRSIG NSEC 5 " +
-                         "3 7200 20100322084538 20100220084538 33495 example." +
-                         "com. FAKEFAKEFAKEFAKE\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("cname-ext.example.com. 3600 IN CNAME www.sql1.examp" +
-                         "le.com.\n", rrs.get_next_rrset().to_text())
-        self.assertEqual("cname-ext.example.com. 7200 IN NSEC cname-int.examp" +
-                         "le.com. CNAME RRSIG NSEC\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("cname-ext.example.com. 3600 IN RRSIG CNAME 5 3 3600" +
-                         " 20100322084538 20100220084538 33495 example.com. F" +
-                         "AKEFAKEFAKEFAKE\ncname-ext.example.com. 3600 IN RRS" +
-                         "IG NSEC 5 3 7200 20100322084538 20100220084538 3349" +
-                         "5 example.com. FAKEFAKEFAKEFAKE\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("cname-int.example.com. 3600 IN CNAME www.example.co" +
-                         "m.\n", rrs.get_next_rrset().to_text())
-        self.assertEqual("cname-int.example.com. 7200 IN NSEC dname.example.c" +
-                         "om. CNAME RRSIG NSEC\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("cname-int.example.com. 3600 IN RRSIG CNAME 5 3 3600" +
-                         " 20100322084538 20100220084538 33495 example.com. F" +
-                         "AKEFAKEFAKEFAKE\ncname-int.example.com. 3600 IN RRS" +
-                         "IG NSEC 5 3 7200 20100322084538 20100220084538 3349" +
-                         "5 example.com. FAKEFAKEFAKEFAKE\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("dname.example.com. 3600 IN DNAME sql1.example.com.\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("dname.example.com. 7200 IN NSEC dns01.example.com. " +
-                         "DNAME RRSIG NSEC\n", rrs.get_next_rrset().to_text())
-        self.assertEqual("dname.example.com. 3600 IN RRSIG DNAME 5 3 3600 201" +
-                         "00322084538 20100220084538 33495 example.com. FAKEF" +
-                         "AKEFAKEFAKE\ndname.example.com. 3600 IN RRSIG NSEC " +
-                         "5 3 7200 20100322084538 20100220084538 33495 exampl" +
-                         "e.com. FAKEFAKEFAKEFAKE\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("dns01.example.com. 3600 IN A 192.0.2.1\n",
-                         rrs.get_next_rrset().to_text())
-        self.assertEqual("dns01.example.com. 7200 IN NSEC dns02.example.com. " +
-                         "A RRSIG NSEC\n", rrs.get_next_rrset().to_text())
-        self.assertEqual("dns01.example.com. 3600 IN RRSIG A 5 3 3600 2010032" +
-                         "2084538 20100220084538 33495 example.com. FAKEFAKEF" +
-                         "AKEFAKE\ndns01.example.com. 3600 IN RRSIG NSEC 5 3 " +
-                         "7200 20100322084538 20100220084538 33495 example.co" +
-                         "m. FAKEFAKEFAKEFAKE\n",
-                         rrs.get_next_rrset().to_text())
-        # there are more than 80 RRs in this zone... let's just count the rest
-        count = 0
-        self.assertEqual(40, len(list(rrs)))
+        rrets = dsc.get_iterator(isc.dns.Name("example.com"))
+        # there are more than 80 RRs in this zone... let's just count them
+        # (already did a full check of the smaller zone above)
+        self.assertEqual(55, len(list(rrets)))
         # TODO should we catch this (iterating past end) and just return None
         # instead of failing?
         self.assertRaises(isc.datasrc.Error, rrs.get_next_rrset)
diff --git a/src/lib/python/isc/datasrc/updater_python.cc b/src/lib/python/isc/datasrc/updater_python.cc
index 5c1cd44..a9dc581 100644
--- a/src/lib/python/isc/datasrc/updater_python.cc
+++ b/src/lib/python/isc/datasrc/updater_python.cc
@@ -45,6 +45,11 @@ using namespace isc::dns::python;
 using namespace isc::datasrc;
 using namespace isc::datasrc::python;
 
+namespace isc_datasrc_internal {
+// See finder_python.cc
+PyObject* ZoneFinder_helper(ZoneFinder* finder, PyObject* args);
+}
+
 namespace {
 // The s_* Class simply covers one instantiation of the object
 class s_ZoneUpdater : public PyObject {
@@ -71,8 +76,6 @@ ZoneUpdater_init(s_ZoneUpdater* self, PyObject* args) {
     return (-1);
 }
 
-// This is a template of typical code logic of python object destructor.
-// In many cases you can use it without modification, but check that carefully.
 void
 ZoneUpdater_destroy(s_ZoneUpdater* const self) {
     // cppobj is a shared ptr, but to make sure things are not destroyed in
@@ -81,8 +84,6 @@ ZoneUpdater_destroy(s_ZoneUpdater* const self) {
     Py_TYPE(self)->tp_free(self);
 }
 
-// These are the functions we export
-//
 PyObject*
 ZoneUpdater_addRRset(PyObject* po_self, PyObject* args) {
     s_ZoneUpdater* const self = static_cast<s_ZoneUpdater*>(po_self);
@@ -138,8 +139,6 @@ ZoneUpdater_commit(PyObject* po_self, PyObject*) {
     }
 }
 
-// These are the functions we export
-//
 PyObject*
 ZoneUpdater_getClass(PyObject* po_self, PyObject*) {
     s_ZoneUpdater* self = static_cast<s_ZoneUpdater*>(po_self);
@@ -173,6 +172,13 @@ ZoneUpdater_getOrigin(PyObject* po_self, PyObject*) {
 PyObject*
 ZoneUpdater_find(PyObject* po_self, PyObject* args) {
     s_ZoneUpdater* const self = static_cast<s_ZoneUpdater*>(po_self);
+    return (isc_datasrc_internal::ZoneFinder_helper(&self->cppobj->getFinder(),
+                                                    args));
+}
+
+PyObject*
+AZoneUpdater_find(PyObject* po_self, PyObject* args) {
+    s_ZoneUpdater* const self = static_cast<s_ZoneUpdater*>(po_self);
     PyObject *name;
     PyObject *rrtype;
     PyObject *target;




More information about the bind10-changes mailing list