Browse Source

make basic removal work again... forgot to get the id to pass to

delItem...

[git-p4: depot-paths = "//depot/": change = 833]
v0.3
John-Mark Gurney 19 years ago
parent
commit
f0a251badb
1 changed files with 11 additions and 6 deletions
  1. +11
    -6
      ContentDirectory.py

+ 11
- 6
ContentDirectory.py View File

@@ -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:


Loading…
Cancel
Save