Re: [sqlalchemy] Encapsulating insert/update logic of mapped classes in the class itself

2014-06-02 Thread Michael Bayer
On Jun 2, 2014, at 1:47 AM, Alex Grönholm alex.gronh...@nextday.fi wrote: This has been a problem for me for years. class DeliveryAddress(Base, Address): ... delivery_method = Column(String) ... @event.listens_for(DeliveryAddress, 'before_insert') def

Re: [sqlalchemy] Encapsulating insert/update logic of mapped classes in the class itself

2014-06-02 Thread Alex Grönholm
That's the first thing I tried, but validators don't get called unless you explicitly set a value to the column. So for something like session.add(DeliveryAddress()), the validator doesn't get called. maanantai, 2. kesäkuuta 2014 14.27.47 UTC+3 Michael Bayer kirjoitti: On Jun 2, 2014, at

Re: [sqlalchemy] Encapsulating insert/update logic of mapped classes in the class itself

2014-06-02 Thread Alex Grönholm
02.06.2014 16:44, Michael Bayer kirjoitti: the ORM can't persist any value for delivery_method unless there is an actual attribute set event. If you are saying session.add(DeliveryAddress()) and flushing, these are the options for deliveryaddress.delivery_method: 1. the value has no setting

[sqlalchemy] Encapsulating insert/update logic of mapped classes in the class itself

2014-06-01 Thread Alex Grönholm
This has been a problem for me for years. class DeliveryAddress(Base, Address): ... delivery_method = Column(String) ... @event.listens_for(DeliveryAddress, 'before_insert') def before_insert_deliveryaddress(mapper, connection, target): settings =