On Aug 13, 2:37 pm, Anton Gritsay <gene...@angri.ru> wrote:
> Hi, Allen!
>
> You can use something like this (yeah, I know that it isn't
> declarative in any way):
>
>     class Node(Base):
>         __tablename__ = 'node'
>         id = Column(Integer, primary_key=True)
>         parent_id = Column(ForeignKey('node.id'))
>
>         parent = relation("Node", remote_side=[id])
>
>         mp_path = Column(sqlamp.PathField())
>         mp_depth = Column(sqlamp.DepthField())
>         mp_tree_id = Column(sqlamp.TreeIdField())
>
>     Node.mp = sqlamp.MPManager(
>         Node.__table__,
>         pk_field='id',
>         parent_id_field='parent_id',
>         path_field_name='mp_path',
>         depth_field_name='mp_depth',
>         tree_id_field_name='mp_tree_id'
>     )
>     Node.__mapper__.extension.append(Node.mp.mapper_extension)
>
> Note that you need to define mp_* colums. You doesn't need it if you
> create MPManager *before* creating mapper.
>



Anton,


Thank you for the help.  And the excellent library. :)

I will try this code out as soon as I can.

Michael B:
Is this the only way to register such an extension with declarative
base?   Can a simpler method be devised?

-- AF
--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to