Is anyone planning on tackling the descriptor fields proposal anytime
soon? If not, I can give it a shot.

I'm not entirely clear as to how to do the ManyToMany and the
auto-generated end of the ForeignKey fields yet. It really feels like
they should just return a Manager instance (that automatically filters
on the original object's id) when they are accessed as an attribute of
an object, and that the Manager should (at least partially) adopt the
proposed descriptor API.

At any rate, Managers and ManyToMany/OneToMany attributes do extremely
similar things, and I think they could share an api and maybe even
share most implementation. If managers behaved like object attributes,
this is what I'm worried about:

MyModel.objects.filter(creator__exact=5)
for obj in MyModel.objects:
    print obj

It seems like people might want to use the objects attribute with
different filter/ordering criteria multiple times. Some sort of
.clone() method would help. In the simple case you just use
MyModel.objects directly, but if you want different result sets, use
.clone()

object_set1 = MyModel.objects.clone()
object_set2 = MyModel.objects.clone()

object_set1.filter(creator__exact=1)
object_set2.filter(creator__exact=2)

Maybe unifying the attribute and manager api's isn't worth the
trouble. I'm sure there are some issues I'm overlooking here, so
please point out any problems you see.

Joseph

Reply via email to