diff options
author | mike <michael.jmontcalm@gmail.com> | 2009-12-14 06:35:13 (GMT) |
---|---|---|
committer | mike <michael.jmontcalm@gmail.com> | 2009-12-14 06:35:13 (GMT) |
commit | 1b539adbe010a63d113a2fac6a2b96ff2621a6c0 (patch) | |
tree | ce860c883a537526bc526df9ea97c61bc619c63d | |
parent | 102c56cabd694f025ea2efb2e2cd3a501c700dfd (diff) |
Rogue commit: Translator : Enabling translation of events
-rw-r--r-- | tutorius/translator.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/tutorius/translator.py b/tutorius/translator.py index 1494173..ee1067b 100644 --- a/tutorius/translator.py +++ b/tutorius/translator.py @@ -196,12 +196,6 @@ class ResourceTranslator(object): def detach(self, activity_id): self._probe_manager.detach(activity_id) - def subscribe(self, event, notification_cb, event_subscribed_cb, error_cb): - return self._probe_manager.subscribe(event, notification_cb, event_subscribed_cb, error_cb) - - def unsubscribe(self, address): - return self._probe_manager.unsubscribe(address) - def register_probe(self, process_name, unique_id): self._probe_manager.register_probe(process_name, unique_id) @@ -249,3 +243,24 @@ class ResourceTranslator(object): def uninstall(self, action_address, is_editing=False): self._probe_manager.uninstall(action_address) + def subscribe_complete_cb(self, event_subscribed_cb, event, address): + event_subscribed_cb(address) + + def event_subscribe_error(self, error_cb, event, exception): + error_cb(event, exception) + + def translator_notification_cb(self, event, notification_cb, new_event): + notification_cb(event) + + def subscribe(self, event, notification_cb, event_subscribed_cb, error_cb): + new_event = copy_module.deepcopy(event) + self.translate(new_event) + + self._probe_manager.subscribe(new_event, + save_args(self.translator_notification_cb, event, notification_cb), + save_args(self.subscribe_complete_cb, event_subscribed_cb, event), + save_args(self.event_subscribe_error, error_cb)) + + def unsubscribe(self, address): + return self._probe_manager.unsubscribe(address) + |