Browse Source

make all Objects have the checkUpdate routine, and just return

self if it isn't there...  This lets us update all children before
sending them down the pipe...

set the size properly...

make FSDirectory have proper order for inheritance, so the Item
checkUpdate doesn't get called instead of the FSObject's

[git-p4: depot-paths = "//depot/": change = 767]
replace/4e84fdb41ea781c7a8f872baa423e8b3be4045a7
John-Mark Gurney 19 years ago
parent
commit
c24e805017
3 changed files with 10 additions and 10 deletions
  1. +2
    -3
      ContentDirectory.py
  2. +3
    -0
      DIDLLite.py
  3. +5
    -7
      FSStorage.py

+ 2
- 3
ContentDirectory.py View File

@@ -124,8 +124,7 @@ class ContentDirectoryControl(UPnPPublisher, dict):
result = {} result = {}


# check to see if object needs to be updated # check to see if object needs to be updated
if ObjectID in self and hasattr(self[ObjectID], 'checkUpdate'):
self[ObjectID].checkUpdate()
self[ObjectID].checkUpdate()


# return error code if we don't exist # return error code if we don't exist
if ObjectID not in self: if ObjectID not in self:
@@ -134,7 +133,7 @@ class ContentDirectoryControl(UPnPPublisher, dict):
try: try:
if BrowseFlag == 'BrowseDirectChildren': if BrowseFlag == 'BrowseDirectChildren':
ch = self.getchildren(ObjectID)[StartingIndex: StartingIndex + RequestedCount] ch = self.getchildren(ObjectID)[StartingIndex: StartingIndex + RequestedCount]
filter(lambda x, s = self, d = didl: d.addItem(s[x.id]) and None, ch)
filter(lambda x, s = self, d = didl: d.addItem(s[x.id].checkUpdate()) and None, ch)
else: else:
didl.addItem(self[ObjectID]) didl.addItem(self[ObjectID])




+ 3
- 0
DIDLLite.py View File

@@ -50,6 +50,9 @@ class Object:
else: else:
self.restricted = '0' self.restricted = '0'


def checkUpdate(self):
return self

def toElement(self): def toElement(self):


root = Element(self.elementName) root = Element(self.elementName)


+ 5
- 7
FSStorage.py View File

@@ -30,7 +30,7 @@ class FSObject(object):
try: try:
nstat = os.stat(self.FSpath) nstat = os.stat(self.FSpath)
if statcmp(self.pstat, nstat): if statcmp(self.pstat, nstat):
return
return self


self.pstat = nstat self.pstat = nstat
self.doUpdate() self.doUpdate()
@@ -41,9 +41,8 @@ class FSObject(object):
self.cd.delItem(self.id) self.cd.delItem(self.id)
else: else:
raise x raise x
except:
import traceback
print traceback.print_exc()

return self


def doUpdate(self): def doUpdate(self):
raise NotImplementedError raise NotImplementedError
@@ -62,7 +61,7 @@ class FSItem(FSObject, Item):


def doUpdate(self): def doUpdate(self):
self.res = Resource(self.url, 'http-get:*:%s:*' % self.mimetype) self.res = Resource(self.url, 'http-get:*:%s:*' % self.mimetype)
self.res.size = os.path.getsize(fpath)
self.res.size = os.path.getsize(self.FSpath)


class FSVideoItem(FSItem, VideoItem): class FSVideoItem(FSItem, VideoItem):
pass pass
@@ -104,7 +103,7 @@ def dofileadd(cd, parent, urlbase, path, name):
return cd.addItem(parent, klass, name, urlbase = urlbase, return cd.addItem(parent, klass, name, urlbase = urlbase,
path = os.path.join(path, name), mimetype = mt) path = os.path.join(path, name), mimetype = mt)


class FSDirectory(StorageFolder, FSObject):
class FSDirectory(FSObject, StorageFolder):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
path = kwargs['path'] path = kwargs['path']
del kwargs['path'] del kwargs['path']
@@ -147,7 +146,6 @@ class FSDirectory(StorageFolder, FSObject):
if nf is not None: if nf is not None:
self.pathObjmap[i] = nf self.pathObjmap[i] = nf
log.msg('i: %s, nf: %s' % (i, nf)) log.msg('i: %s, nf: %s' % (i, nf))
self.cd[nf].checkUpdate()


# sort our children # sort our children
log.msg('doUpdate: %s, sorting: %s' % (self.title, list.__str__(self))) log.msg('doUpdate: %s, sorting: %s' % (self.title, list.__str__(self)))


Loading…
Cancel
Save