Browse Source

fix handling updating.. I've been running this for a long time

so I think it's good..

[git-p4: depot-paths = "//depot/": change = 1665]
main
John-Mark Gurney 12 years ago
parent
commit
1499b7a828
1 changed files with 14 additions and 7 deletions
  1. +14
    -7
      DIDLLite.py

+ 14
- 7
DIDLLite.py View File

@@ -265,9 +265,11 @@ class Item(Object):
needupdate = True needupdate = True


def doUpdate(self, child=False): def doUpdate(self, child=False):
Container.doUpdate(self.cd[self.parentID])
# do NOT update parent container per 2.2.9 for # do NOT update parent container per 2.2.9 for
# ContainerUpdateID changes # ContainerUpdateID changes
# must be Container.didUpdate, otherwise we could update the
# parent when we really just want to update the ID
Container.didUpdate(self.cd[self.parentID])


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


@@ -327,7 +329,7 @@ class Container(Object, list):
childCount = property(lambda x: len(x)) childCount = property(lambda x: len(x))
searchable = None searchable = None
updateID = 0 updateID = 0
needupdate = False
needcontupdate = False


_optionattrs = Object._optionattrs.copy() _optionattrs = Object._optionattrs.copy()
_optionattrs.update({ _optionattrs.update({
@@ -342,6 +344,7 @@ class Container(Object, list):
Object.__init__(self, cd, id, parentID, title, **kwargs) Object.__init__(self, cd, id, parentID, title, **kwargs)
list.__init__(self) list.__init__(self)
self.doingUpdate = False self.doingUpdate = False
self.needcontupdate = False
self.oldchildren = {} self.oldchildren = {}


def genCurrent(self): def genCurrent(self):
@@ -373,8 +376,8 @@ class Container(Object, list):
if self.doingUpdate: if self.doingUpdate:
return return
self.doingUpdate = True self.doingUpdate = True
self.needcontupdate = False


didupdate = False
children = self.genChildren() children = self.genChildren()
if isinstance(children, dict): if isinstance(children, dict):
oldchildren = self.oldchildren oldchildren = self.oldchildren
@@ -419,17 +422,21 @@ class Container(Object, list):
if klass is not None: if klass is not None:
self.cd.addItem(self.id, klass, name, *args, self.cd.addItem(self.id, klass, name, *args,
**kwargs) **kwargs)
didupdate = True
self.needcontupdate = True


# sort our children # sort our children
self.sort() self.sort()


if didupdate:
self.didUpdate()

self.doingUpdate = False self.doingUpdate = False


if self.needcontupdate:
self.didUpdate()

def didUpdate(self): def didUpdate(self):
if self.doingUpdate:
self.needcontupdate = True
return

if self.id == '0': if self.id == '0':
self.updateID = (self.updateID + 1) self.updateID = (self.updateID + 1)
else: else:


Loading…
Cancel
Save