I'm having a problem deleting a MK object which is a member of a list.
Assume the following model:
Class Attribute Type
-------------------------------------
Item
container Container
name string
Container
name string
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[0] )
store.saveChanges()
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).
Cheers,
Jason
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss