Soni Bergraj wrote:
> I'm tinkering with many-to-many relationships and more specific with
> self references.
> Let's stick with a bunch of Tradesmen (just as an example). One
> Tradesman knows several suppliers and purchasers. And all of them are
> This gives us the following scheme:
> ------------- * purchaser
> | Tradesman |-----------
> ------------- |
> *| |
> supplier | |
> My solution so far is:
> class Tradesman(SQLObject):
> name = StringCol(alternateID = True)
> suppliers = RelatedJoin('Tradesman',
> addRemoveName = 'Supplier',
> joinColumn = 'purchaser', otherColumn = 'supplier')
> purchasers = RelatedJoin('Tradesman',
> addRemoveName = 'Purchaser',
> joinColumn = 'supplier', otherColumn = 'purchaser')
> This way it seems to work smoothly. The only drawback is that table
> creation fails with an error due to the attempt to create the table
> 'tradesman_tradesman' twice.
> Is this the most convenient way to do self references, and if yes, is
> there a way to prevent the second attempt to create 'tradesman_tradesman'?
Use intermediateTable to tell sqlobject to use a different table name.