On 4/11/07, svilen <[EMAIL PROTECTED]> wrote: > is from_attr makeing sense for plain atributes, e.g. integers ot > whatever?
You got a point here. It doesn't work (or even make sense) on plain attributes. > if no, maybe choose something like from_relation Fine with me. > or filter_relation or > filter_relation_tomany or similar if it is expected to only work over > relations - and multiple-instances relations; i.e. it is useless over > single pointer-like 1:1 relation - so the name would suggest the > proper target-type. It works fine for "to_one" relations. I'm not sure if anybody will ever use it on such relations, but since it works as expected, I see no reason to artificially constrain the thing to "to_many" relationships. > > On Wednesday 11 April 2007 11:50:53 Gaetan de Menten wrote: > > On 4/10/07, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > hm, why is from_attr a classmethod ? > > > > Because that way, you don't have to specify the related class at > > all, and you can specify the parameters as args not kwargs. See my > > first initial remark: > > > > * I've implemented Query.from_attr, instead of adding new keywords > > to the Query "constructor", because I think: > > > > Query.from_attr(someuser, 'addresses') > > > > looks better, is shorter and is more readable than: > > > > Query('Address', instance=someuser, attr_name='addresses') > > > > > not very consistent with all the other generative methods ? > > > > True, but I think it makes more sense this way (see below). > > > > > can we have a regular generative method as well ? > > > > If you really want one, I'll gladly do it, but I don't think it > > makes sense because that method can possibly change the mapper. > > > > So, first I'd need to duplicate part of what is in the __init__ > > method, which doesn't feel right. > > > > And second, I think it could be quite confusing for a user. Imagine > > that Query(A).from_attr(inst, 'rel') could return instances of B > > (or whatever class is attached to the relation)... Probably not > > what you'd expect. So, if we go down that route, it would probably > > be a good idea to check that the mapper in the cloned query is the > > same than the one we get from the relation. > > > > And by the way, from_attr doesn't sound like a generative method, > > so if you want it, what about "filter_from_attr", or something > > similar? > -- Gaƫtan de Menten http://openhex.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---