diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-09-05 15:23:44 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-09-05 15:23:44 +0000 |
| commit | 0fbb67b71a91a1c6f792812474f45a52333aa227 (patch) | |
| tree | e093752e5e52335d71b3b6a7ea5395309b8149eb /examples/association | |
| parent | f432bd3550443fb27711e463b086deae7c3096df (diff) | |
| download | sqlalchemy-0fbb67b71a91a1c6f792812474f45a52333aa227.tar.gz | |
synchronize inherited does not need to be called for the full mapper hierarchy
Diffstat (limited to 'examples/association')
| -rw-r--r-- | examples/association/proxied_association.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/association/proxied_association.py b/examples/association/proxied_association.py index ccd092f95..ed3afd597 100644 --- a/examples/association/proxied_association.py +++ b/examples/association/proxied_association.py @@ -29,21 +29,22 @@ orderitems = Table('orderitems', metadata, metadata.create_all() +class OrderItem(object): + def __init__(self, item, price=None): + self.item = item + self.price = price is None and item.price or price + class Order(object): def __init__(self, customer_name): self.customer_name = customer_name items = AssociationProxy('itemassociations', 'item', - creator=lambda x: OrderItem(x)) + creator=OrderItem) class Item(object): def __init__(self, description, price): self.description = description self.price = price -class OrderItem(object): - def __init__(self, item, price=None): - self.item = item - self.price = price is None and item.price or price mapper(Order, orders, properties={ 'itemassociations':relation(OrderItem, cascade="all, delete-orphan", lazy=False) |
