On Nov 24, 3:11 pm, Conor <conor.edward.da...@gmail.com> wrote:
> Here is one way you can define your secondary table and ListNode:
>
> class ListNode(Node):
>     __mapper_args__ = {'polymorphic_identity': 'list'}
>     __tablename__ = 'nodes_list'
>
>     id = Column(Integer, ForeignKey('nodes.id'), primary_key=True)
>     contents = relation(
>         'ListNodeContents',
>         backref='list_node',
>         cascade='all,delete-orphan',
>         collection_class=ordering_list('position'),
>         order_by=lambda: [ListNodeContents.position],
>         primaryjoin=lambda: (
>             ListNodeContents.list_node_id == ListNode.__table__.c.id))
>     nodes = association_proxy(
>         'contents',
>         'node',
>         creator=lambda node: ListNodeContents(node=node))
>

Conor - thanks very much for such a detailed answer. If I can impose
on your time for a couple of clarifications, I'd appreciate it.

1) backref='list_node' generates "KeyError: list_node" - I thought
perhaps it should be 'nodes_list' but that generated the same error.
What should backref be?

2) collection_class=ordering_list('position') seems to cause
"AttributeError: 'NoteNode' object has no attribute 'position'". Seems
like that should be referring to the position over in
ListNodeContents; I tried 'ListNodeContents.position' with the same
failure.

As you can tell, I'm sort of feeling around in the dark here.  When I
get SQLA stuff to work, it always seems simple in retrospect, and I'm
hoping the same thing happens here.  Thanks for any additional help
you can provide!

--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.


Reply via email to