>> > I assume you have a reason not to use:
>> >
>> > class x(SQLObject):
>> > ys = ForeignKey( 'y' )
>>
>> Well, in the real life example I have the two objects 'x' and 'y' are
>> kinda like 'article' and 'tag'. A tag can be attached to several
>> articles and an article can have several tags attached to it.
>>
>> So I guess I have to use RelatedJoin on both.
>
> A typical task for many-to-many relation.
Eventually I ended up doing this:
################################
class x(SQLObject):
ys = RelatedJoin( 'x' )
class y(SQLObject):
xs = RelatedJoin( 'y' )
myx = x.get( 1 )
myy = y.get( 1 )
if myx not in myy.xs:
myy.addX( myx )
################################
Simple enough :)
Cheers,
Daniel
--
Psss, psss, put it down! - http://www.cafepress.com/putitdown
|