Re: [sqlalchemy] How to properly use a property for self._value or self.parent.value

2012-05-02 Thread Michael Bayer
On May 2, 2012, at 8:34 AM, Moritz Schlarb wrote: > Thank you, Michael! > > But could I achieve it somehow using hybrid properties and a case statement? > > I tried something like: > > @hybrid_property > def time(self): > return self._time or self.event.time > > @time.

Re: [sqlalchemy] How to properly use a property for self._value or self.parent.value

2012-05-02 Thread Moritz Schlarb
Thank you, Michael! But could I achieve it somehow using hybrid properties and a case statement? I tried something like: @hybrid_property def time(self): return self._time or self.event.time @time.expression def time(cls): return case([(cls._time != None, cls

Re: [sqlalchemy] How to properly use a property for self._value or self.parent.value

2012-04-21 Thread Michael Bayer
On Apr 21, 2012, at 7:06 AM, Moritz Schlarb wrote: > > So basically, a Child object may set it's own value for time, but if it's not > set, it uses the value from its parent. > This works, but I would also like to be able to do something like: > > session.query(Child).filter(Child.parent.anoth

[sqlalchemy] How to properly use a property for self._value or self.parent.value

2012-04-21 Thread Moritz Schlarb
Hi at all, I haven't found something by googling, but I'm also not sure about the right search terms, so I hope some can help me here. I have a model like this: class Parent(DeclarativeBase): id = Column(Integer, primary_key=True) time = Column(Float) another_id = Column(Integer) cl