On Thu, 21 Aug 2008, Frank Niessink wrote: > I'm not sure your analysis is correct. patterns.Composite does not > copy the children, it only copies the list containing the children: > > class Composite(object): > ... > def __getstate__(self): > return dict(children=self.__children[:], parent=self.__parent) > > def __setstate__(self, state): > self.__parent = state['parent'] > self.__children = state['children']
See the mail I just sent, in trunk there is an actual deep copy of the children :) > Copying a list this way (l[:]) creates a shallow copy; it's a new > list, but it contains the same objects. To illustrate: Actually, I ran trunk for half a day by replacing the children=[child.copy() for child in self.__children] with children=[self.__children[:]] in Composite.__getstate__. I dind't realize that the copy stuff appeared in trunk. But I'm not sure this fix is right, after all there is probably a reason why you changed the shallow copy for a deep one in trunk ? This seems to be part of the 'domain objects may have any other domain object as children' change. Cheers Jérôme
