Apologies for any stupidity, but I'm struggling with some joined table
inheritance, I have the following code:

widgets_table = sa.Table('web_widgets', meta.metadata,
    sa.Column('widget_id', sa.types.Integer, primary_key=True),
    sa.Column('title',sa.types.String(length=255)),
    sa.Column('widget_type', sa.types.String(30), nullable=False),
    sa.Column('position', sa.types.Integer),
    sa.Column('page_id', sa.types.Integer, sa.ForeignKey('web_pages.id'))
)

video_widget_table = sa.Table('web_video_widget', meta.metadata,
    sa.Column('widget_id', sa.types.Integer,
sa.ForeignKey('web_widgets.widget_id'), primary_key=True),
    sa.Column('teaser', sa.types.String(length=10000)),
    sa.Column('body',sa.types.String(length=21845)),
    sa.Column('image', sa.types.String(length=256))
)

class ArkWebWidget(object):
    def __init__(self):
        pass

class ArkWebVideoWidget(object):
    def __init__(self):
        pass


orm.mapper(ArkWebWidget, widgets_table,
           polymorphic_on=widgets_table.c.widget_type,
           polymorphic_identity='widget'
)

orm.mapper(ArkWebVideoWidget, video_widget_table,
           inherits=ArkWebWidget,
           polymorphic_identity='video_widget'
)

---------------------------

However, when I run this I get an error:

...
  File "C:\ark\env_x64\lib\site-packages\sqlalchemy-0.6.2-py2.6.egg\sqlalchemy\o
rm\__init__.py", line 818, in mapper
    return Mapper(class_, local_table, *args, **params)
  File "C:\ark\env_x64\lib\site-packages\sqlalchemy-0.6.2-py2.6.egg\sqlalchemy\o
rm\mapper.py", line 207, in __init__
    self._configure_inheritance()
  File "C:\ark\env_x64\lib\site-packages\sqlalchemy-0.6.2-py2.6.egg\sqlalchemy\o
rm\mapper.py", line 231, in _configure_inheritance
    (self.class_.__name__, self.inherits.class_.__name__))
sqlalchemy.exc.ArgumentError: Class 'ArkWebVideoWidget' does not inherit from 'A
rkWebWidget'

And I'm really not sure what I've done wrong, it seems ok based on
what is written in the docs?

Any pointers much appreciated.

Jules

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