On Tue, 2013-01-22 at 19:58:15 +0200, Alexey Vihorev wrote: > > That's what you want in this case, that this hybrid property would > > get a class, because Query works with classes. Try adding echo=True > > to create_engine() to see the actual SQL emitted, it should be > > correct. > > No, that's definitely not what I want. My hybrid property relies on a > content of an instance to return a value, so it needs that 'self' > parameter to be an instance.
But the whole idea of hybrid properties and methods is to work on both classes and their instances. Since you're using class in a query, you get a class as self argument. When that query returns a result (an instance of this class), the hybrid property will work on that instance as well. I also recreated your hybrid example and I can't see any problems: the query emits correct SQL, and hybrid on returned instance also works. -- Audrius Kažukauskas http://neutrino.lt/
pgpI5G9CTPKnC.pgp
Description: PGP signature
