Just Launched: You can now import projects and releases from Google Code onto SourceForge
We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps. Read More
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.
From: Jason Hildebrand <jason@...>
To: webware-discuss <webware-discuss@...>
Subject: problem deleting MiddleKit objects
Date: 20 Mar 2002 15:39:17 -0600
I'm having a problem deleting a MK object which is a member of a list.
Assume the following model:
Class Attribute Type
items list of Item
Now suppose there are two instances of Item (Item.1 and Item.2), one
instance of container (Container.1) and both Items are contained in
Container.1. That is, Item.1.container() == Item.2.container() ==
Container.1 (please excuse the abuse of notation).
Now I do something like:
c = store.fetchObject( 'Container', 1 )
items = c.items()
print len(items) # should be two
# delete one of the items
store.deleteObject( items )
print len( c.items() ) # should be one, but is still two
The reason is that the Container object caches its list of Items
internally as self._items, but after the Item is deleted, it doesn't
know to refresh its list. So, short of calling store.clear() to toss
out all cached objects (or restarting the app server), I can't convince
Container.1 that it now contains only one Item. If I try to reference
the "ghost" Item, I get a dangling reference error (which is correct).
Is this simply a matter of MiddleKit not being complete? Or is this
problem somehow unique to me?
After spending a considerable amount of time going through the MK
source, I suspect the former. If this is the case, I'll take a crack at
implementing the correct behaviour (now that I finally grok what's going
on, it doesn't seem too difficult to fix).
I didn't notice this problem until recently, since I was instantiating
a new store on every request (which is dumb). Now I have one global
store, which is the way (I think) MiddleKit was intended to be used
(although the docs don't really say much about this -- it would be good
to add some of these "big picture" assumptions to the user guide).