From f0a251badb62aaeda3070694aac896bd5c379ffa Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Fri, 7 Jul 2006 13:03:56 -0800 Subject: [PATCH] make basic removal work again... forgot to get the id to pass to delItem... [git-p4: depot-paths = "//depot/": change = 833] --- ContentDirectory.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ContentDirectory.py b/ContentDirectory.py index 836a6ab..3d4af5f 100644 --- a/ContentDirectory.py +++ b/ContentDirectory.py @@ -105,18 +105,23 @@ class ContentDirectoryControl(UPnPPublisher, dict): i = klass(self, nid, parent, title, *args, **kwargs) if hasattr(i, 'content'): self.webbase.putChild(nid, i.content) + #log.msg('children:', `self.children[parent]`, `i`) self.children[parent].append(i) self[i.id] = i return i.id + def has_key(self, key): + return dict.has_key(self, key) + def delItem(self, id): if not self.has_key(id): log.msg('already removed:', id) return - log.msg('removing:', id) + #log.msg('removing:', id) if isinstance(self[id], Container): + #log.msg('children:', Container.__repr__(self.children[id]), map(None, self.children[id])) while self.children[id]: - self.delItem(self.children[id][0]) + self.delItem(self.children[id][0].id) assert len(self.children[id]) == 0 del self.children[id] # Remove from parent @@ -205,11 +210,11 @@ class ContentDirectoryControl(UPnPPublisher, dict): # XXX - technically if list changed, we need to get # some new ones by looping till we have a complete # list. - ochup = filter(lambda x, s = self: + ochup = filter(lambda x, s = self: s.has_key(x.id) and s[x.id].checkUpdate() is not None, ch) - # XXX - are we suppose to be calling addContainer - # for Containers instead of always addItem? - #log.msg('ochup:', `ochup`) + if len(ochup) != len(ch): + log.msg('ch:', `ch`, 'ochup:', `ochup`) + raise RuntimeError, 'something disappeared' filter(lambda x, d = didl: d.addItem(x) and None, ochup) total = len(self.getchildren(ObjectID)) else: