Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-14 Thread Michael Williamson
On Fri, 11 Nov 2016 13:27:09 -0500 mike bayer wrote: > > > On 11/11/2016 12:18 PM, Michael Williamson wrote: > > > > That still requires the repetition of the name of the attribute, > > which I'd rather avoid. I've put together a variation on > > hybrid_property which

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread mike bayer
On 11/11/2016 12:18 PM, Michael Williamson wrote: That still requires the repetition of the name of the attribute, which I'd rather avoid. I've put together a variation on hybrid_property which automatically assigns the label by scanning through the class dict. It could probably do with a bit

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Michael Williamson
On Fri, 11 Nov 2016 11:59:52 -0500 mike bayer wrote: > > > On 11/11/2016 07:20 AM, Michael Williamson wrote: > > I'm using hybrid_property, and would like the key of the property > > to be set to the attribute name, rather than the name of the > > getter. This is

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread mike bayer
On 11/11/2016 07:20 AM, Michael Williamson wrote: I'm using hybrid_property, and would like the key of the property to be set to the attribute name, rather than the name of the getter. This is because I'm generating a getter function based on some args, rather than having the caller directly

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Michael Williamson
On Friday, November 11, 2016 at 2:22:28 PM UTC, Simon King wrote: > > On Fri, Nov 11, 2016 at 1:53 PM, Michael Williamson > wrote: > > > >> I think your code is basically fine, you've just got a mistake on the > >> last line. Presumably you meant to query Person, not

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Simon King
On Fri, Nov 11, 2016 at 1:53 PM, Michael Williamson wrote: > >> I think your code is basically fine, you've just got a mistake on the >> last line. Presumably you meant to query Person, not Person.born? > > > I want Person.born so that I don't have to get the entire object. It

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Michael Williamson
> I think your code is basically fine, you've just got a mistake on the > last line. Presumably you meant to query Person, not Person.born? > I want Person.born so that I don't have to get the entire object. It doesn't make much difference in this example, but is quite important for us in

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Simon King
On Fri, Nov 11, 2016 at 12:20 PM, Michael Williamson wrote: > I'm using hybrid_property, and would like the key of the property to be set > to the attribute name, rather than the name of the getter. This is because > I'm generating a getter function based on some args, rather

[sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Michael Williamson
I'm using hybrid_property, and would like the key of the property to be set to the attribute name, rather than the name of the getter. This is because I'm generating a getter function based on some args, rather than having the caller directly defining the getter. As a minimal example: from