On 1/26/06, Robert Wittams <[EMAIL PROTECTED]> wrote: > > Joseph Kocherhans wrote: > > On 1/26/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > >>I'm not a fan of .all() either - if you can do .filter() on > >>Article.objects, then surely Article.objects is already a collection of > >>some kind. That's what is sounds like: Article.objects == all the > >>'Article' objects. > > > > > > And there's the original problem that started this mess ;-) Let me see > > if I can lay it all out. (Sorry to pick on your response Luke, not > > trying to single you out.) > > > > Case 1: > > Let's assume that MyModel.objects or my_object.related_set *IS* a > > Query object (in other words, it has state): > > I have absolutely no idea how you arrived at this weirdo stateful model > - it clearly makes absolutely no sense wrt concurrency.
Wow. I'm not even sure how I got to that point now. > > Case 2: > > Let's assume that MyModel.objects and my_object.related_set *RETURN* a > > *NEW* Query object. (In other words is stateless.) You might expect > > this: > > > > MyModel.objects # Q1 > > MyModel.objects.filter(*args) # Q1 with filters applied > > MyModel.objects.order_by(*args) # Q1 with ordering applied > > > > But in fact, you'll get this: > > > > MyModel.objects # Q1 > > MyModel.objects.filter(*args) # Q2 > > MyModel.objects.order_by(*args) # Q3 > > > > But this works fine: > > > > q = MyModel.objects # q is Q1 > > q.filter(*args) # q is Q1 with filters applied > > q.order_by(*args) # q is Q1 with ordering applied > > I really have no idea what you are talking about here. Sorry. > > The only interpretation I can make is that you are worried about making > multiple database calls when you . The only alternative to this is to > reimplement a relational database in python. Do you really want to do > the filtering client side? Or what? I am having real trouble grasping > your issue here. Nevermind. I was making an (erroneous and old) assumption that you could modify the state of a query instance like: q.filter() q.order_by() When in fact Adrian's proposal specifically says that filter() and order_by() would return new query instances, not modify q's state (a dict of filter criteria or whatever) I'm sorry :( To do the above, you would have to chain the methods like: q.filter().order_by() or reassign q q = q.filter() q = q.order_by() I'm happy now. +1 on MyModel.objects -> new Query instance rather than MyModel.objects.all() Sorry for the confusion. Hopefully this clears things up for someone else as well. Joseph