From: Jelte Jansen Date: Mon, 4 Jun 2012 12:26:05 +0000 (+0200) Subject: [2018] Use updater instead of separate finders X-Git-Tag: trac2351_base~226^2~59^2~7^2^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6f8dbd0f299c6c0f97cf24e87116fa32f43c8a0f;p=thirdparty%2Fkea.git [2018] Use updater instead of separate finders --- diff --git a/src/lib/python/isc/ddns/session.py b/src/lib/python/isc/ddns/session.py index ff30b6765a..fa51d0e5f9 100644 --- a/src/lib/python/isc/ddns/session.py +++ b/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) diff --git a/src/lib/python/isc/ddns/tests/session_tests.py b/src/lib/python/isc/ddns/tests/session_tests.py index 87cd255cf2..cbcac128aa 100644 --- a/src/lib/python/isc/ddns/tests/session_tests.py +++ b/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 diff --git a/src/lib/python/isc/xfrin/diff.py b/src/lib/python/isc/xfrin/diff.py index 2d3f93736c..a3a9d7d08a 100644 --- a/src/lib/python/isc/xfrin/diff.py +++ b/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