Jonathan LaCour wrote: > I am attempting to model a doubly-linked list, as follows:
Replying to myself: task_table = Table('task', metadata, Column('id', Integer, primary_key=True), Column('name', Unicode), Column('next_task_id', Integer, ForeignKey('task.id')), Column('previous_task_id', Integer, ForeignKey('task.id')) ) class Task(object): def __init__(self, **kw): for key, value in kw.items(): setattr(self, key, value) def __repr__(self): return '<Task :: %s>' % self.name mapper(Task, task_table, properties={ 'next_task' : relation( Task, primaryjoin=task_table.c.next_task_id==task_table.c.id, uselist=False, remote_side=task_table.c.id, backref=backref( 'previous_task', primaryjoin=task_table.c.previous_task_id==task_table.c.id, uselist=False ) ), }) ... seems to do the trick. I had tried using backref's earlier, but it was failing because I was specifying a "remote_side" keyword argument to the backref(), which was making it blow up with cycle detection exceptions for some reason. -- Jonathan LaCour http://cleverdevil.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---