X-Git-Url: http://git.maemo.org/git/?p=jamaendo;a=blobdiff_plain;f=jamaui%2Fpostoffice.py;h=078316c0dfc22866925fa7f3c266c819523c9a98;hp=9453176f4b0adbab72afa7f27c7e641e5a8af7ff;hb=facd2a5710fb05ac80d55ed8e1af8184fb496c02;hpb=ef38e67e9c769af43ed190f810daf8c2e164a125;ds=sidebyside diff --git a/jamaui/postoffice.py b/jamaui/postoffice.py index 9453176..078316c 100644 --- a/jamaui/postoffice.py +++ b/jamaui/postoffice.py @@ -35,24 +35,26 @@ class PostOffice(object): def notify(self, tag, *data): clients = self.tags.get(tag) if clients: - #log.debug("(%s %s) -> [%s]", - # tag, - # " ".join(str(x) for x in data), - # " ".join(repr(x) for x,_ in clients)) for ref, client in clients: client(*data) def connect(self, tag, ref, callback): - if tag not in self.tags: - self.tags[tag] = [] - clients = self.tags[tag] - if callback not in clients: - clients.append((ref, callback)) + if not isinstance(tag, list): + tag = [tag] + for t in tag: + if t not in self.tags: + self.tags[t] = [] + clients = self.tags[t] + if callback not in clients: + clients.append((ref, callback)) def disconnect(self, tag, ref): - if tag not in self.tags: - self.tags[tag] = [] - self.tags[tag] = [(_ref, cb) for _ref, cb in self.tags[tag] if _ref != ref] + if not isinstance(tag, list): + tag = [tag] + for t in tag: + if t not in self.tags: + self.tags[t] = [] + self.tags[t] = [(_ref, cb) for _ref, cb in self.tags[t] if _ref != ref] postoffice = PostOffice()