sure its along these lines


class Content(my_declarative_base):
     __tablename__ = 'content'
     id = Column(Integer, primary_key=True)
     title = Column(String(80))
     parent_id = Column(Integer, ForeignKey('content.id'))
     type = Column(String(32))

     children = relation("Content", backref=backref('parent',  
remote_side=id))

     __mapper_args__ = {'polymorphic_on':type,  
'polymorphic_identity':'content'}



On Nov 11, 2008, at 10:13 AM, cropr wrote:

>
> Does somebody know if is possible to use a declarative class
> definition for the schema below
>
> ####
> content  = Table('content', meta.metadata,
>    Column('id', types.Integer, primary_key=True, autoincrement=True),
>    Column('title', types.String(80)),
>    Column('parent_id', types.Integer, ForeignKey('content.id')),
>    Column('type',types.String(32)),
>    )
>
> class Content(object):
>
> mapper(Content, content, polymorphic_on=content.c.type,
> polymorphic_identity='content', properties={
>    'children': relation(Content, backref=backref('parent',
> remote_side=[content.c.id]))
>    })
> ####
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to