# Currently I have to do this: from sqlalchemy import Table, Column, Text, Integer
Base = sqlahelper.get_base() sometable = Table('sometable', Base.metadata, Column('id', Integer, primary_key=True), Column('discriminator', Text), Column('data', Text)) class SomeClass(Base): __table__ = sometable __mapper_args__ = {'polymorphic_on': sometable.c.discriminator, 'polymorphic_identity': 'default'} # Meanwhile, the following way of doing it doesn't work. # But it seems like it would make sense and might be worth enabling. class SomeClass(Base): __table__ = Table('sometable', Base.metadata, Column('id', Integer, primary_key=True), Column('discriminator', Text), Column('data', Text)) __mapper_args__ = {'polymorphic_on': 'discriminator', 'polymorphic_identity': 'default'} # Attempting to do it this way gives this error: AttributeError: 'str' object has no attribute 'proxy_set' Doesn't really matter to me, it's no extra effort to define the table outside of the class, and in fact sometimes I need to do that in order to share the table with other modules. But it does seem that this is a mistake that could be easily made, and my main point is that the error it causes is not very clear. The error would be fine if it quoted the piece of code which triggered it, for instance if it said: * AttributeError: 'str' object 'discriminator' has no attribute 'proxy_set'. That still wouldn't be particularly descriptive of what went wrong, but it might help someone find their error more quickly in the future. In my case I was just lucky to remember that I had recently altered this particular file and was able to guess what the cause of the problem was. -- 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.