[Modeling-users] inheritance and relations confusion
Status: Abandoned
Brought to you by:
sbigaret
From: Mario R. <ma...@ru...> - 2003-11-13 17:46:47
|
Hi, I have an entity (B) inheriting from another (A), with the constraint that any instance of either must be related to one instance of B. The corresponding model is therefore: model.entities = [ Entity('A', ...), Entity('B', parent='A', ...), ] model.associations=[ # A is always related to a B Association('A','B', relations=['b','as'], multiplicity=[ [1,1], [0,None] ], delete=['nullify','deny'], keys=['fkBId','id'], ), ] I can create the instances and rels in the expected way, but when I come to delete them, there is a problem: I try to get to the b for the a in question, to nullify the relation (respecting the "deny" delete rule). Thus I do: > > > a = ec.fetch('A',qualifier='...',isDeep=1)[0] # gives correct a > > > b = a.getB() > > > b .<pympack.A.A instance at 0x95ba60> > > > for related_a in b.getAs(): b.removeFromAs(related_a) Traceback (most recent call last): for related_a in b.getAs(): AttributeError: A instance has no attribute 'getAs' Thus, he insists that the b instance is of type A, and does not find the getAs() rel-method on it (but the id and other b-only non-rel attributes are correctly present!). But, removing known objects "explicitly", with : a.removeObjectFromBothSidesOfRelationshipWithKey(b,'b') as many times as necessary (for each a related to this b) works just fine. Any enlightenment? Cheers, mario ps: ah, but when did relations ever behave nicely when inheritance is involved ;-? |