Michael Bayer wrote: > Chris Withers wrote: >> All the tests bar test_mapper_args_composite pass, and that currently >> blows up with a rather bizarre: > > There's a Column there getting sent to the mapper that doesn't yet have a > key. It's None, so you get that error. Declarative sets up those > keys/names on the columns in the metaclass so somehow this test is messing > up the order of initialization. I'll try to have a deeper look.
I think the likely cause is this: class MyMixin1: type_ = Column(String(50)) __mapper_args__=dict(polymorphic_on=type_) __mixin__ = True the metaclass makes a copy of "type_", but that doesn't access "type_" inside of __mapper_args__. So a full feature here would need to dig into __mapper_args__, identify all Column objects that are on the mixin class, and ensure the copies are placed in those collections. Probably as we go through each column, store old/new in a lookup dictionary. then do a copy of __mapper_args__ using that lookup for column objects located. this is the kind of messy scenario that makes it very time consuming for some recipes to become supported features. > > > >> >> Traceback (most recent call last): >> File "test_mixable.py", line 177, in test_mapper_args_composite >> class MyModel(Base,MyMixin1,MyMixin2): >> File "mixable.py", line 27, in __init__ >> return DeclarativeMeta.__init__(cls, classname, bases, dict_) >> File >> "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/ext/declarative.py", >> line 561, in __init__ >> _as_declarative(cls, classname, dict_) >> File >> "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/ext/declarative.py", >> line 554, in _as_declarative >> cls.__mapper__ = mapper_cls(cls, table, properties=our_stuff, >> **mapper_args) >> File >> "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/__init__.py", >> line 751, in mapper >> return Mapper(class_, local_table, *args, **params) >> File >> "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/mapper.py", >> line 198, in __init__ >> self._configure_properties() >> File >> "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/mapper.py", >> line 514, in _configure_properties >> if self._should_exclude(col.key, col.key, local=False): >> File >> "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/mapper.py", >> line 985, in _should_exclude >> if getattr(self.class_, assigned_name, None)\ >> TypeError: Error when calling the metaclass bases >> getattr(): attribute name must be string >> >> Any idea what's causing that? If I move the type_ columns the the >> __mapper_args__ to MyModel, the tests passes... >> >> (also note evilness required because declarative gets __table_args__ >> from dict_ rather than the cls, where it should ;-) ) >> >> cheers, >> >> Chris >> -- >> 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. >> >> > > -- > 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. > > -- 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.