Browse Source

prevent redundant DoHierarchy adds/removes

Darren Ranalli 19 years ago
parent
commit
193478aacf

+ 6 - 0
direct/src/distributed/ClientRepositoryBase.py

@@ -218,6 +218,9 @@ class ClientRepositoryBase(ConnectionRepository):
             self.doId2do[doId] = distObj
             # and update it.
             distObj.generate()
+            # make sure we don't have a stale location
+            distObj.parentId = None
+            distObj.zoneId = None
             distObj.setLocation(parentId, zoneId)
             distObj.updateRequiredFields(dclass, di)
             # updateRequiredFields calls announceGenerate
@@ -262,6 +265,9 @@ class ClientRepositoryBase(ConnectionRepository):
             self.doId2do[doId] = distObj
             # and update it.
             distObj.generate()
+            # make sure we don't have a stale location
+            distObj.parentId = None
+            distObj.zoneId = None
             distObj.setLocation(parentId, zoneId)
             distObj.updateRequiredOtherFields(dclass, di)
             # updateRequiredOtherFields calls announceGenerate

+ 17 - 13
direct/src/distributed/DoCollectionManager.py

@@ -194,25 +194,28 @@ class DoCollectionManager:
     def storeObjectLocation(self, object, parentId, zoneId):
         oldParentId = object.parentId
         oldZoneId = object.zoneId
-        if ((None not in (oldParentId, oldZoneId)) and
-            ((oldParentId != parentId) or (oldZoneId != zoneId))):
+        if (oldParentId != parentId) or (oldZoneId != zoneId):
             # Remove old location
             self.deleteObjectLocation(object, oldParentId, oldZoneId)
         elif oldParentId == parentId and oldZoneId == zoneId:
             # object is already at that parent and zone
             return
-        if (parentId is None) or (zoneId is None):
+
+        if ((parentId is None) or (zoneId is None) or
+            (parentId == zoneId == 0)):
             # Do not store null values
-            return
-        # Add to new location
-        self._doHierarchy.storeObjectLocation(object, parentId, zoneId)
-        # this check doesn't work because of global UD objects;
-        # should they have a location?
-        #assert len(self._doHierarchy) == len(self.doId2do)
+            object.parentId = None
+            object.zoneId = None
+        else:
+            # Add to new location
+            self._doHierarchy.storeObjectLocation(object, parentId, zoneId)
+            # this check doesn't work because of global UD objects;
+            # should they have a location?
+            #assert len(self._doHierarchy) == len(self.doId2do)
 
-        # Set the new parent and zone on the object
-        object.parentId = parentId
-        object.zoneId = zoneId
+            # Set the new parent and zone on the object
+            object.parentId = parentId
+            object.zoneId = zoneId
 
         if 1:
             # Do we still need this
@@ -229,7 +232,8 @@ class DoCollectionManager:
             
     def deleteObjectLocation(self, object, parentId, zoneId):
         # Do not worry about null values
-        if (parentId is None) or (zoneId is None):
+        if ((parentId is None) or (zoneId is None) or
+            (parentId == zoneId == 0)):
             return
         if 1:
             # Do we still need this