Default subclass objects in Sqlalchemy?

Posted by Timmy on Stack Overflow See other posts from Stack Overflow or by Timmy
Published on 2010-04-20T22:18:56Z Indexed on 2010/04/20 22:43 UTC
Read the original article Hit count: 166

Filed under:
|
|

im using the example from the pylons book

orm.mapper(Comment, comment_table)
orm.mapper(Tag, tag_table)
orm.mapper(Nav, nav_table, polymorphic_on=nav_table.c.type, polymorphic_identity='nav')
orm.mapper(Section, section_table, inherits=Nav, polymorphic_identity='section')
orm.mapper(Page, page_table, inherits=Nav, polymorphic_identity='page', properties={
   'comments':orm.relation(Comment, backref='page', cascade='all'),
   'tags':orm.relation(Tag, secondary=pagetag_table)
})

i am mostly copying from this, but is there a simple way have a default Page that gets referenced, but if users requests a change, create a new Page object? thanks

i want something similar to this

class DefaultPage(Page):
     __init__(self):
          self.a = a
          self.b = b
          self.c = c

orm.mapper(DefaultPage, None, inherits=Nav, yada yada )

© Stack Overflow or respective owner

Related posts about sqlalchemy

Related posts about python