def register_for(self, callback, types, topics, sources, fast=True): if types is None: types = [ALL] if topics is None: topics = [ALL] if sources is None: sources = [ALL] callback = CollectableCallback(callback, fast) for event_type in types: self.types.setdefault(event_type, {})[callback.guid] = callback for source in sources: self.sources.setdefault(source, {})[callback.guid] = callback for topic in topics: self.topics.setdefault(topic, {})[callback.guid] = callback callback.types = types callback.topics = topics callback.sources = sources return callback.guid
def register_for(self, callback, types, topics, sources, fast = True): if types is None: types = [ALL] if topics is None: topics = [ALL] if sources is None: sources = [ALL] callback = CollectableCallback(callback, fast) for event_type in types: self.types.setdefault(event_type, {})[callback.guid] = callback for source in sources: self.sources.setdefault(source, {})[callback.guid] = callback for topic in topics: self.topics.setdefault(topic, {})[callback.guid] = callback callback.types = types callback.topics = topics callback.sources = sources return callback.guid
def unregister(self, guid): callback = CollectableCallback.get_callback(guid) for event_type in callback.types: try: del (self.types[event_type][guid]) except KeyError: pass for topic in callback.topics: try: del (self.topics[topic][guid]) except KeyError: pass for source in callback.sources: try: del (self.sources[source][guid]) except KeyError: pass return
def unregister(self, guid): callback = CollectableCallback.get_callback(guid) for event_type in callback.types: try: del(self.types[event_type][guid]) except KeyError: pass for topic in callback.topics: try: del(self.topics[topic][guid]) except KeyError: pass for source in callback.sources: try: del(self.sources[source][guid]) except KeyError: pass return