Re: [sqlalchemy] Combine attributes from two objects in parent object

2012-06-20 Thread Stephan Hügel
On Saturday, 26 May 2012 00:36:54 UTC+1, Michael Bayer wrote: > > > usually @property achieves this: > > class Correspondent(Base): > @property > def email_address(self): > return self.corr_1.email_address if self.corr_1 else > self.corr_2.email_address > > This worked perfectly,

Re: [sqlalchemy] Combine attributes from two objects in parent object

2012-05-25 Thread Michael Bayer
On May 25, 2012, at 4:53 PM, Stephan Hügel wrote: > I'd like to represent a Correspondent object, which can refer to two separate > objects > > Corr_1 > - id > - email_address > > Corr_2 > - id > - email_address > > Correspondent > - id > - corr_1.id > - corr_2.id > > But I have two problems

[sqlalchemy] Combine attributes from two objects in parent object

2012-05-25 Thread Stephan Hügel
I'd like to represent a Correspondent object, which can refer to two separate objects Corr_1 - id - email_address Corr_2 - id - email_address Correspondent - id - corr_1.id - corr_2.id But I have two problems: I'm using MySQL, so I can't use a check constraint to ensure that only one of the c