From 9eb753bf56f10f52549614d2a44f8f6c4fdd83f2 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Sat, 8 Jul 2006 20:05:15 -0800 Subject: [PATCH] include object in result buffer if it exists... don't repr the return value, the dict containing it will do that for me... don't go into subchildren and update them to pull in there children just to find out the childCount... DIDLLite now doesn't include it if there aren't any... (This may need to be tested w/ the Intel software, but works great w/ the D-Link DSM-520)... It makes browsing shoutcast genres doable now.. [git-p4: depot-paths = "//depot/": change = 852] --- ContentDirectory.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/ContentDirectory.py b/ContentDirectory.py index 2da39ab..bef2b5b 100644 --- a/ContentDirectory.py +++ b/ContentDirectory.py @@ -179,6 +179,8 @@ class ContentDirectoryControl(UPnPPublisher, dict): def soap_Browse(self, *args): l = {} debug.appendnamespace(reqname, l) + if self.has_key(args[0]): + l['object'] = self[args[0]] l['query'] = 'Browse(ObjectID=%s, BrowseFlags=%s, Filter=%s, ' \ 'StartingIndex=%s RequestedCount=%s SortCriteria=%s)' % \ tuple(map(repr, args)) @@ -188,7 +190,7 @@ class ContentDirectoryControl(UPnPPublisher, dict): except defer.Deferred, x: ret = doRecallgen(x, self.soap_Browse, *args) - l['response'] = `ret` + l['response'] = ret return ret @@ -207,24 +209,13 @@ class ContentDirectoryControl(UPnPPublisher, dict): # check to see if object needs to be updated self[ObjectID].checkUpdate() - # return error code if we don't exist + # return error code if we don't exist anymore if ObjectID not in self: raise errorCode(701) if BrowseFlag == 'BrowseDirectChildren': ch = self.getchildren(ObjectID)[StartingIndex: StartingIndex + RequestedCount] - # filter out the ones that don't exist anymore, we need - # to check against None, since some dirs might be empty - # (of valid content) but exist. - # 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: s.has_key(x.id) and - s[x.id].checkUpdate() is not None, ch) - 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) + filter(lambda x, d = didl: d.addItem(x) and None, ch) total = len(self.getchildren(ObjectID)) else: didl.addItem(self[ObjectID])