I am all down with the power of mixins. The reason I mapped things this way
is because I do have concrete instances of string, amount, and quantity.
(I'm capturing data from receipts: "string" can be e.g. a receipt number,
amount can be e.g. a total, and quantity can be something unaffiliated with
a line item, like "number of seats reserved".
I finally got this to work by re-declaring all the properties I wanted
using declared_attr on the "final" class, like the below. Which is fine in
this case, but slightly more annoying in the other case I have, where there
are quite a few inherited properties.
-ethan
class EvidenceLineItem(EvidenceAmount, EvidenceQuantity, EvidenceString):
__mapper_args__ = { 'polymorphic_identity':
ProofItemClassType.line_item }
@declared_attr
def string(cls):
return Evidence.__table__.c.get('string',Column(String(length=255),
index=True))
@declared_attr
def quantity(cls):
return Evidence.__table__.c.get('quantity',Column(Integer))
@declared_attr
def amount(cls):
return Evidence.__table__.c.get('amount',Column(Integer,
index=True))
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sqlalchemy/-/VuHxC54meNsJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.