Re: Possible improvement to model API

2007-02-15 Thread jk
On Feb 10, 7:38 am, David Abrahams <[EMAIL PROTECTED]> wrote: > Trying to take the temperature here: is there any sympathy here for > the idea of adding it to contrib/, or is the whole idea simply > anathema to this group? For me, the idea looks great. I will not hold my breath waiting it to be

Re: Possible improvement to model API

2007-02-15 Thread alfborge
On Feb 10, 5:38 am, David Abrahams <[EMAIL PROTECTED]> wrote: > "James Bennett" <[EMAIL PROTECTED]> > writes: > Can't argue with your subjective opinion. But I suggest you ask some > newbies what they think. Also, "prettiness" is not really one of my > goals, though I believe that generally come

Re: Possible improvement to model API

2007-02-10 Thread David Abrahams
"Karen Tracey" <[EMAIL PROTECTED]> writes: > "Karen Tracey" <[EMAIL PROTECTED]> > writes: > > The fix for #2348 changes the error from "Unbound local error" to "Type > error: cannot > resolve > > keyword [whatever] into field". > > Illustrating just why the current sy

Re: Possible improvement to model API

2007-02-10 Thread Karen Tracey
On 2/10/07, David Abrahams <[EMAIL PROTECTED]> wrote: > > > "Karen Tracey" <[EMAIL PROTECTED]> > writes: > > The fix for #2348 changes the error from "Unbound local error" to "Type > error: cannot resolve > > keyword [whatever] into field". > > Illustrating just why the current syntax is hard to gi

Re: Amendment: Possible improvement to model API

2007-02-10 Thread David Abrahams
"Adrian Holovaty" <[EMAIL PROTECTED]> writes: > On 2/9/07, David Abrahams <[EMAIL PROTECTED]> wrote: >> Entry.objects.filter( >> _.headline.startswith('What') & >> ~(_.pub_date>=datetime.now()) & >> _.pub_date>=datetime(2005, 1, 1)) > > David, > > Looks like you don't like

Re: Possible improvement to model API

2007-02-10 Thread David Abrahams
"Karen Tracey" <[EMAIL PROTECTED]> writes: > On 2/9/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > > However, you have obviously been bitten by a bad error message - I > would suggest that a good course of action would be to raise a ticket > with your specific example so that th

Re: Possible improvement to model API

2007-02-10 Thread Karen Tracey
On 2/9/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > > > However, you have obviously been bitten by a bad error message - I > would suggest that a good course of action would be to raise a ticket > with your specific example so that the error reporting of that part of > the query engine can

Re: Amendment: Possible improvement to model API

2007-02-09 Thread Adrian Holovaty
On 2/9/07, David Abrahams <[EMAIL PROTECTED]> wrote: > Entry.objects.filter( > _.headline.startswith('What') & > ~(_.pub_date>=datetime.now()) & > _.pub_date>=datetime(2005, 1, 1)) David, Looks like you don't like Django's database API. Sorry you don't like it, but we can

Re: Possible improvement to model API

2007-02-09 Thread David Abrahams
"James Bennett" <[EMAIL PROTECTED]> writes: > First thoughts: subjectively, I'm not sure it'd be any prettier than > what we have now. Can't argue with your subjective opinion. But I suggest you ask some newbies what they think. Also, "prettiness" is not really one of my goals, though I belie

Re: Possible improvement to model API

2007-02-09 Thread James Bennett
First thoughts: subjectively, I'm not sure it'd be any prettier than what we have now. I'm also wary of overloading the concepts of the standard Python operators when whet we're really doing is translating to SQL operations -- sooner or later, there's going to be an impedance mismatch. I'm also n

Re: Possible improvement to model API

2007-02-09 Thread David Abrahams
Malcolm Tredinnick <[EMAIL PROTECTED]> writes: > On Fri, 2007-02-09 at 21:14 -0500, David Abrahams wrote: >> _.foo >= 6 returns an expression tree, an object that represents >> the comparison of the foo field with 6. This technique is well-known >> among advanced C++ programmers but has also be

Re: Possible improvement to model API

2007-02-09 Thread Malcolm Tredinnick
On Fri, 2007-02-09 at 21:14 -0500, David Abrahams wrote: > Malcolm Tredinnick <[EMAIL PROTECTED]> > writes: [...] > > Maybe I'm missing something, but I don't see how this can work at all. > > When Python sees "_.foo >= 6", it is going to evaluate it at runtime > > (before calling the function).

Re: Amendment: Possible improvement to model API

2007-02-09 Thread David Abrahams
"Lawrence Oluyede" <[EMAIL PROTECTED]> writes: >> > --- >> > from django.models import field as _ >> > >> > Entry.objects.filter( >> > _.headline.startswith('What')).exclude( >> > _.pub_date>=datetime.now()).filter( >> > _.pub_date>=datetime(2005, 1, 1)) >> >> Should b

Re: Amendment: Possible improvement to model API

2007-02-09 Thread Lawrence Oluyede
> > --- > > from django.models import field as _ > > > > Entry.objects.filter( > > _.headline.startswith('What')).exclude( > > _.pub_date>=datetime.now()).filter( > > _.pub_date>=datetime(2005, 1, 1)) > > Should be: > > Entry.objects.filter( > _.headline.startswith(

Re: Possible improvement to model API

2007-02-09 Thread David Abrahams
Malcolm Tredinnick <[EMAIL PROTECTED]> writes: > On Sat, 2007-02-10 at 08:30 +0800, Russell Keith-Magee wrote: >> On 2/10/07, David Abrahams <[EMAIL PROTECTED]> wrote: >> > >> >Use natural operators for filtering, excluding, and attribute >> >access. >> >> > How about it? >> >> Some imm

Re: Possible improvement to model API

2007-02-09 Thread David Abrahams
"Russell Keith-Magee" <[EMAIL PROTECTED]> writes: > On 2/10/07, David Abrahams <[EMAIL PROTECTED]> wrote: >> >>Use natural operators for filtering, excluding, and attribute >>access. > >> How about it? > > Some immediate problems: > > - Your syntax works for < > <= >= and ==; but what abo

Re: Possible improvement to model API

2007-02-09 Thread Malcolm Tredinnick
On Sat, 2007-02-10 at 08:30 +0800, Russell Keith-Magee wrote: > On 2/10/07, David Abrahams <[EMAIL PROTECTED]> wrote: > > > >Use natural operators for filtering, excluding, and attribute > >access. > > > How about it? > > Some immediate problems: > > - Your syntax works for < > <= >= an

Re: Possible improvement to model API

2007-02-09 Thread Russell Keith-Magee
On 2/10/07, David Abrahams <[EMAIL PROTECTED]> wrote: > >Use natural operators for filtering, excluding, and attribute >access. > How about it? Some immediate problems: - Your syntax works for < > <= >= and ==; but what about all the other Django query operators? How do you come up with

Amendment: Possible improvement to model API

2007-02-09 Thread David Abrahams
David Abrahams <[EMAIL PROTECTED]> writes: > --- > from django.models import field as _ > > Entry.objects.filter( > _.headline.startswith('What')).exclude( > _.pub_date>=datetime.now()).filter( > _.pub_date>=datetime(2005, 1, 1)) Should be: Entry.objects.filter(

Possible improvement to model API

2007-02-09 Thread David Abrahams
What's wrong with this picture? TimeDivision.objects.filter(when__ge=datetime(2007,5,14)) Whoops. "Greater or equal" is spelled 'gte' and not 'ge' in Django's model API. After having fallen into this trap and getting a cryptic error message (UnboundLocalError: local variable 'new_opts' refer