On Sun, Dec 03, 2006 at 07:20:30PM -0500, Jonathan Wight wrote:
> class Node(InheritableSQLObject):
>       parent = ForeignKey('Node', default = None)
>       children = MultipleJoin('Node', joinColumn = 'parent_id')
> 
> class ContentNode(Node):
>       content = StringCol(default = None)
> 
> class Page(ContentNode):
>       comments = MultipleJoin('Comment', joinColumn = 'parent_id')
> 
> class Comment(ContentNode):
>       pass
> 
> thePage = Page(content = 'Page 1')
> theComment = Comment(content = 'Comment 1')
> theComment.parent = thePage
> 
> print thePage.children
> 
> print thePage.comments

   The program seems to be wrong. You created multiple joins from Page
to Comment, but have forgotten to create a reverse foreign key. The tables
have to be AFAIU

class Page(ContentNode):
        comments = MultipleJoin('Comment', joinColumn = 'pages_id')

class Comment(ContentNode):
>       pages = ForeignKey('Page', default = None)

   Then
print thePage.comments
   works and prints an empty list. Of course - nobody has linked any
comment to the page.

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to