Michael Bayer wrote:
I reworked your mixin system in rae3ec57eea8c to fully traverse all of
cls.__mro__ every time and to be very explicit about rules for the current
class vs. classes that we definitely know are mixins. So the above works
as well as if you just put the ComputedMapperArgs on the base (which is
probably preferable here).
Cool, thanks for this...
I updated
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/DeclarativeMixins basde
on your code and against the test suite I have for that recipe here.
Incidentally, with the code in the recipe, this works:
class Report(Base):
__tablename__ = 'report'
__table_args__ = {'mysql_engine':'InnoDB'}
python_type = Column(String(64))
@classproperty
def __mapper_args__(cls):
if cls.__name__=='Feed':
return dict(polymorphic_on=cls.python_type)
else:
return dict(polymorphic_identity=cls.__name__)
class AReport(Report):
pass
It doesn't on current trunk/tip/whatever, based on this testcase:
def test_mapper_args_classproperty_three(self):
class Person(Base):
__tablename__ = 'people'
id = Column(Integer, primary_key=True)
discriminator = Column('type', String(50))
@classproperty
def __mapper_args__(cls):
if cls.__name__=='Person':
return dict(polymorphic_on=cls.discriminator)
else:
return dict(polymorphic_identity=cls.__name__)
class Engineer(Person):
pass
compile_mappers()
assert class_mapper(Person).polymorphic_on is \
Person.__table__.c.type
eq_(class_mapper(Engineer).polymorphic_identity, 'Engineer')
...but I guess that's okay :-)
Now, the only test I can't get to work with the mixin recipe is
test_table_args_inherited_single_table_inheritance.
I see how you've fixed this for 0.6, but it makes me wonder why the
__table_args__ check is there at all? They're essentially benign, right?
(since in the test case above, it really doesn't make sense for Specific
to have __table_args__ inside _as_declarative... I can't think of a test
case where it would be problematic...)
cheers,
Chris
no thanks needed, feel free to divert .0001 pence of every transaction
onto our Paypal link.... :)
I'll see what I can do ;-)
--
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.