Browse Source

[2018] Use updater instead of separate finders

Jelte Jansen 13 years ago
parent
commit
6f8dbd0f29

+ 7 - 2
src/lib/python/isc/ddns/session.py

@@ -247,7 +247,12 @@ class UpdateSession:
             self.__diff = isc.xfrin.diff.Diff(datasrc_client, zname,
                                               journaling=True,
                                               single_update_mode=True)
-            _, self.__finder = datasrc_client.find_zone(zname)
+            # Note that while it is really the ZoneUpdater that is set
+            # here, it is still called finder, as the only methods that
+            # are and should be used on this object are find() and find_all()
+            # (ZoneUpdater provides the ZoneFinder interface itself, no
+            # separate get_zone_finder())
+            self.__finder = self.__diff.get_updater()
             self.__zname = zname
             self.__zclass = zclass
             self.__datasrc_client = datasrc_client
@@ -591,7 +596,7 @@ class UpdateSession:
                                                    rrset.get_type(),
                                                    ZoneFinder.NO_WILDCARD |
                                                    ZoneFinder.FIND_GLUE_OK)
-        if result == self.__finder.CNAME:
+        if result == ZoneFinder.CNAME:
             # Ignore non-cname rrs that try to update CNAME records
             # (if rrset itself is a CNAME, the finder result would be
             # SUCCESS, see next case)

+ 6 - 6
src/lib/python/isc/ddns/tests/session_tests.py

@@ -114,6 +114,12 @@ class SessionTestBase(unittest.TestCase):
                                                  self._acl_map))
         self._session._UpdateSession__get_update_zone()
 
+    def tearDown(self):
+        # With the Updater created in __get_update_zone, and tests
+        # doing all kinds of crazy stuff, one might get database locked
+        # errors if it doesn't clean up explicitely after each test
+        self._session = None
+
     def check_response(self, msg, expected_rcode):
         '''Perform common checks on update resposne message.'''
         self.assertTrue(msg.get_header_flag(Message.HEADERFLAG_QR))
@@ -282,12 +288,6 @@ class SessionTest(SessionTestBase):
 
         self.assertEqual(expected, strings)
 
-    def __prereq_helper(self, method, expected, rrset):
-        '''Calls the given method with self._datasrc_client
-           and the given rrset, and compares the return value.
-           Function does not do much but makes the code look nicer'''
-        self.assertEqual(expected, method(rrset))
-
     def __check_prerequisite_exists_combined(self, method, rrclass, expected):
         '''shared code for the checks for the very similar (but reversed
            in behaviour) methods __prereq_rrset_exists and

+ 10 - 0
src/lib/python/isc/xfrin/diff.py

@@ -376,3 +376,13 @@ class Diff:
             raise ValueError("Separate buffers requested in single-update mode")
         else:
             return (self.__deletions, self.__additions)
+
+    def get_updater(self):
+        """
+        Returns the ZoneUpdater associated with this Diff instance.
+        While update statements can be used on this updater, its main
+        goal is to provide the ZoneFinder interface for searching through
+        the zone as it was on the moment the updater was created.
+        If the Diff has been committed, this will return None.
+        """
+        return self.__updater