On Wednesday 27 March 2002 09:10 am, Jason Hildebrand wrote: > The attached patch fixes this problem. > > Implementation: If an object such as "Item" is deleted, it checks all > objects which it references (like Container), and gets each of these > objects to remove it from any list attributes they might have. > > It would be great if someone (Geoff?) could apply this to CVS.
Okay, disregard my earlier "send me the patch" message. I just hadn't seen this message yet. And now I see the patch is just plain text. :-) Overall it looks good. It does the black magic I mentioned, but automatically. However, I want to leave this out of 0.7 final, because I don't have time to test with various apps and add some test cases for it beforehand. Sorry I didn't see this earlier. We can do this right after 0.7 final. Some comments on the patch itself: - Kill the delattr(). The setattr() immediately afterwards is sufficient. - In updateReferencingListAttrs() the "obj = self.valueForAttr(attr)" will pull in an obj that is not yet in memory. Which then will pull in the lists (since it asked to removeObjectFromListAttrs()) which results in a lot of work for nothing. We can probably check for this via the store's _objects dictionary and avoid this extra "thrashing". - Likewise the removeObjectFromListAttrs() doesn't have to look at a list unless it's in memory (e.g., not None) so it should check the raw attribute instead of valueForAttr(). - We have to make some test cases around this. Like delete a listed object then add a new object to the list and save changes. Should work, but you never know until you try... And delete a listed object, add a new object to the list, delete another listed object, add an existing object to the list, and save changes. (See MiddleKit/Tests/ and be sure to run Test.py) But the patch is definitely clever. It relies on the fact that objects in lists always have "back refs" to the objects containing them. And you obviously "get" the whole klass and attr definitions idea to have written this. Now my brain is officially full for the night. If you wanna take a crack at the above improvements, it would be much appreciated and you would learn even more about MK internals. ;-) I did my part today adding indexes and speeding up fetches. :-) Thanks, -Chuck _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
