BIND 10 trac2931, updated. 18b3c00bb06e51f6a3b16fa634983a43f65b8e97 [2931] Allow unsubscribing from notifications
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Jul 1 11:50:08 UTC 2013
The branch, trac2931 has been updated
via 18b3c00bb06e51f6a3b16fa634983a43f65b8e97 (commit)
from 79fe7149c3d2cc20d4bef791d27d5316702de53b (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 18b3c00bb06e51f6a3b16fa634983a43f65b8e97
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date: Mon Jul 1 13:49:30 2013 +0200
[2931] Allow unsubscribing from notifications
Includes minor test fixes.
-----------------------------------------------------------------------
Summary of changes:
src/lib/python/isc/config/ccsession.py | 19 +++++++++++++++++++
src/lib/python/isc/config/tests/ccsession_test.py | 6 +++---
2 files changed, 22 insertions(+), 3 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/config/ccsession.py b/src/lib/python/isc/config/ccsession.py
index 9adc89c..4dd73b7 100644
--- a/src/lib/python/isc/config/ccsession.py
+++ b/src/lib/python/isc/config/ccsession.py
@@ -624,6 +624,8 @@ class ModuleCCSession(ConfigData):
The callback should not raise exceptions, such exceptions are
likely to propagate through the loop and terminate program.
+ Returns: Opaque id of the subscription. It can be used to cancel
+ the subscription by unsubscribe_notification.
"""
self._last_notif_id += 1
my_id = self._last_notif_id
@@ -636,6 +638,23 @@ class ModuleCCSession(ConfigData):
{ my_id: callback }
return (notification_group, my_id)
+ def unsubscribe_notification(self, nid):
+ """
+ Remove previous subscription for notifications. Pass the id returned
+ from subscribe_notification.
+
+ Throws:
+ - CCSessionError: for low-level communication errors.
+ - KeyError: The id does not correspond to valid subscription.
+ """
+ (group, cid) = nid
+ del self._notification_callbacks[group][cid]
+ if not self._notification_callbacks[group]:
+ # Removed the last one
+ self._session.group_unsubscribe(CC_GROUP_NOTIFICATION_PREFIX +
+ group)
+ del self._notification_callbacks[group]
+
class UIModuleCCSession(MultiConfigData):
"""This class is used in a configuration user interface. It contains
specific functions for getting, displaying, and sending
diff --git a/src/lib/python/isc/config/tests/ccsession_test.py b/src/lib/python/isc/config/tests/ccsession_test.py
index 7652789..9c33ef6 100644
--- a/src/lib/python/isc/config/tests/ccsession_test.py
+++ b/src/lib/python/isc/config/tests/ccsession_test.py
@@ -431,14 +431,14 @@ class TestModuleCCSession(unittest.TestCase):
mccs.check_command()
self.assertEqual(fake_session.message_queue, [])
self.assertEqual(notifications, [
- ("second", "event", {'param': True})
+ ("first", "event", {'param': True})
])
del notifications[:]
# If we try to unsubscribe again, it complains.
- self.assertRaises(KeyError, self.unsubscribe_notification, id1)
+ self.assertRaises(KeyError, mccs.unsubscribe_notification, id2)
# Unsubscribe the other one too. From now on, it doesn't eat the
# messages again.
- mccs.unsubscribe_notification(id2)
+ mccs.unsubscribe_notification(id1)
fake_session.group_sendmsg({"notification": ["event", {
"param": True
}]}, "notifications/group")
More information about the bind10-changes
mailing list