From 1499b7a828d1bf90f9ec5e4e29ae4b4f7dc2eec9 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Fri, 7 Dec 2012 00:04:11 -0800 Subject: [PATCH] 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] --- DIDLLite.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/DIDLLite.py b/DIDLLite.py index 1ef13ec..7da11d7 100644 --- a/DIDLLite.py +++ b/DIDLLite.py @@ -265,9 +265,11 @@ class Item(Object): needupdate = True def doUpdate(self, child=False): - Container.doUpdate(self.cd[self.parentID]) # do NOT update parent container per 2.2.9 for # 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): @@ -327,7 +329,7 @@ class Container(Object, list): childCount = property(lambda x: len(x)) searchable = None updateID = 0 - needupdate = False + needcontupdate = False _optionattrs = Object._optionattrs.copy() _optionattrs.update({ @@ -342,6 +344,7 @@ class Container(Object, list): Object.__init__(self, cd, id, parentID, title, **kwargs) list.__init__(self) self.doingUpdate = False + self.needcontupdate = False self.oldchildren = {} def genCurrent(self): @@ -373,8 +376,8 @@ class Container(Object, list): if self.doingUpdate: return self.doingUpdate = True + self.needcontupdate = False - didupdate = False children = self.genChildren() if isinstance(children, dict): oldchildren = self.oldchildren @@ -419,17 +422,21 @@ class Container(Object, list): if klass is not None: self.cd.addItem(self.id, klass, name, *args, **kwargs) - didupdate = True + self.needcontupdate = True # sort our children self.sort() - if didupdate: - self.didUpdate() - self.doingUpdate = False + if self.needcontupdate: + self.didUpdate() + def didUpdate(self): + if self.doingUpdate: + self.needcontupdate = True + return + if self.id == '0': self.updateID = (self.updateID + 1) else: