ActiveMapper usage question

3 views
Skip to first unread message

Graham_Higgins

unread,
Jul 29, 2006, 12:34:50 PM7/29/06
to TurboGears
Trying to translate some "inherited" Turboblog SQLObject code to
SQLAlchemy. The Comment class sets up a parent-child relationship
referencing back into the same table:

class Comment(ActiveMapper):
class mapping:
__table__= "comment"
comment_id = column(Integer, primary_key=True)
...
parent_id = column(Integer, default=-1)
sub_comments = one_to_many("Comment", colname="comment_id",
backref="parent_id")

The sqlalchemy exception is:

ArgumentError: Cant find any foreign key relationships between
'comment' and 'comment'

I can see how that might be the case. Is there a recommended way of
doing this using ActiveMapper or do I need to revert to a Table +
mapper setup as exemplified in the zblog code in the sqlalchemy svn
repos
(http://www.sqlalchemy.org/trac/browser/zblog/trunk/lib/zblog/database)?

Cheers,

Graham

Graham_Higgins

unread,
Jul 29, 2006, 12:40:13 PM7/29/06
to TurboGears
Sorry, I omitted key info. The exception occurs when running "tg-admin
sql create"

Reply all
Reply to author
Forward
0 new messages