Re: [Modeling-users] inheritance and relations confusion
Status: Abandoned
Brought to you by:
sbigaret
From: Sebastien B. <sbi...@us...> - 2003-11-13 23:12:45
|
Mario Ruggier <ma...@ru...> wrote: > 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: >=20 > model.entities =3D [ > Entity('A', ...), > Entity('B', parent=3D'A', ...), > ] > model.associations=3D[ > # A is always related to a B > Association('A','B', > relations=3D['b','as'], > multiplicity=3D[ [1,1], [0,None] ], > delete=3D['nullify','deny'], > keys=3D['fkBId','id'], > ), > ] Okay, so you have a kind of a reflexive relationship on the inheritance tree of A, joining A to Bs (and thus, B to Bs) --your 'b' should then be related to a 'B' itself, maybe himself, or you have a cycle there. That's fine, I just want to make it clear so that we understand each other. > 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: >=20 > > > > a =3D ec.fetch('A',qualifier=3D'...',isDeep=3D1)[0] # gives correc= t a > > > > b =3D 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' >=20 > 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!). I made some tries but really could not get into this situation: whatever I try, getB() always returns 'B' instances, never 'A' instances. Could you please give the exact sequence of operations leading to this particular situation? I'm probably too tired now for this, but I cannot find of a way to make this happen, so a complete sequence of instructions revealing the bug would be a great help. Thanks! > But, removing known objects "explicitly", with : >=20 > a.removeObjectFromBothSidesOfRelationshipWithKey(b,'b') >=20 > as many times as necessary (for each a related to this b) works > just fine. >=20 > Any enlightenment? > > Cheers, mario >=20 > ps: ah, but when did relations ever behave nicely when inheritance is > involved ;-? ...and how come you find some many bugs in one day? I thought this was somehow regulated by an international agreement!?!! Thanks for reporting, and looking forward to see what makes this happen, -- S=E9bastien. |