Re: Proposal: deprecated Model.__init__(*args)

2008-02-04 Thread Brian Harring
On Tue, Jan 29, 2008 at 03:43:22PM -0600, Jacob Kaplan-Moss wrote: > On 1/29/08, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > > Yes, but why not have fromtuple classmethod optimized for this use- > > case? And I believe this way of initialization could be really faster > > than keyword initializati

Re: Proposal: deprecated Model.__init__(*args)

2008-02-03 Thread David Cramer
I somehow can't see the custom_query solving our issues with needing custom queries. How is it going to handle JOINs? On Feb 2, 4:06 pm, "Adrian Holovaty" <[EMAIL PROTECTED]> wrote: > On Jan 29, 2008 2:13 PM, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > > > I'd like to deprecate initializing mo

Re: Proposal: deprecated Model.__init__(*args)

2008-02-02 Thread Adrian Holovaty
On Jan 29, 2008 2:13 PM, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > I'd like to deprecate initializing models using positional arguments > (i.e. ``p = Person(1, 'Joe Somebody')``) in favor of only allowing > keyword-argument initialization (i.e. ``p = Person(id=1, name='Joe > Somebody')``). I

Re: Proposal: deprecated Model.__init__(*args)

2008-02-01 Thread Malcolm Tredinnick
On Tue, 2008-01-29 at 14:13 -0600, Jacob Kaplan-Moss wrote: > Howdy folks -- > > The short version: > > I'd like to deprecate initializing models using positional arguments > (i.e. ``p = Person(1, 'Joe Somebody')``) in favor of only allowing > keyword-argument initialization (i.e. ``p = Person(

Re: Proposal: deprecated Model.__init__(*args)

2008-02-01 Thread Malcolm Tredinnick
On Tue, 2008-01-29 at 12:50 -0800, Ivan Illarionov wrote: > > One of the other things planned as part of qs-rf is the ability to use > > custom queries to initialize models -- something like > > ``Model.objects.custom_query("SELECT ...")`` > That's not enough - I need this feature to initialize m

Re: Proposal: deprecated Model.__init__(*args)

2008-01-30 Thread Empty
> I'd like to deprecate initializing models using positional arguments > (i.e. ``p = Person(1, 'Joe Somebody')``) in favor of only allowing > keyword-argument initialization (i.e. ``p = Person(id=1, name='Joe > Somebody')``). +1 from me. I've been doing some interesting model stuff lately and th

Re: Proposal: deprecated Model.__init__(*args)

2008-01-30 Thread Justin Bronn
I'm +1 for deprecating positional arguments from __init__(). > Relying on the order of fields in the model definition is asking for a > heaping load of fail. Hence my desire to see it go away. While I agree this argument applies for having positional args in __init__(), those instantiating using

Re: Proposal: deprecated Model.__init__(*args)

2008-01-30 Thread Jacob Kaplan-Moss
On 1/30/08, Nicola Larosa <[EMAIL PROTECTED]> wrote: > No, wait, make that +1 to erasing the ruttin' posargs "feature" from the > gorram *language*. Dong ma? Whoa, now, don't go quoting Firefly on me or we'll be here all day :) Jacob --~--~-~--~~~---~--~~ You rec

Re: Proposal: deprecated Model.__init__(*args)

2008-01-30 Thread Jacob Kaplan-Moss
On 1/30/08, Ned Batchelder <[EMAIL PROTECTED]> wrote: > I'm not arguing against removing positional argument support from model > constructors, just wondering about the 1.0 focus. Yeah, you're totally right that the feature is a perfect post-1.0 candidate. I'm just using it as a vehicle for getti

Re: Proposal: deprecated Model.__init__(*args)

2008-01-30 Thread Ned Batchelder
I would have thought Adrian's deferred fields proposal would fall squarely in the post-1.0 bucket. It clearly has no backward compatibility issues, so it can be added after 1.0. Maybe you aren't proposing to include it in 1.0; it wasn't clear from your message. I'm not arguing against removi

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Nicola Larosa
Jacob Kaplan-Moss wrote: > I'd like to deprecate initializing models using positional arguments > (i.e. ``p = Person(1, 'Joe Somebody')``) in favor of only allowing > keyword-argument initialization (i.e. ``p = Person(id=1, name='Joe > Somebody')``). Huh? +1 to that. No, wait, make that +1 to e

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread [EMAIL PROTECTED]
The use of *args also seems like it will be a barrier/just messy if/ when schema evolution ever gets(or with 3rd party apps), I'm +1 on this. On Jan 29, 8:01 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On Jan 30, 2008 8:57 AM, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > > > > >

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Russell Keith-Magee
On Jan 30, 2008 8:57 AM, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > > There should be one-- and preferably only one --obvious way to do it. > ... > > On top of that, as I keep saying, it leads to brittle code -- I've > been bitten a number of times. ... > Relying on the order of fields

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Ivan Illarionov
http://pastebin.com/m62466a6b --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send ema

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Ivan Illarionov
Then it makes sense to check for number of arguments (len(args) == len(obj._meta.fields)) and raise an error if it's not equal to number of fields. The *args instantiation is useful and fast. QSRF improvements may make it less useful nut **kwargs instantiation just always be slower due to the natu

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Jacob Kaplan-Moss
On 1/29/08, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > Jacob, why are you opposed to alternative instantiation methods? >>> import this ... There should be one-- and preferably only one --obvious way to do it. ... On top of that, as I keep saying, it leads to brittle code -- I'

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Ivan Illarionov
> I'm pretty strongly opposed to a fromtuple (or whatever) method: it's > brittle and to tightly couples code to the arbitrary order of defined > fields. Jacob, why are you opposed to alternative instantiation methods? Standard Python does it with dict.fromkeys() Why not? --~--~-~--~~-

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Ivan Illarionov
Speed: >>> t1.timeit() # Model.__init__ from django trunk with args stuff stripped 179.84739959966981 >>> t2.timeit() 139.67626695571641 # Model.fromargs() Implementation: def fromtuple(cls, values): dispatcher.send(signal=signals.pre_init, sender=cls, args=values, kwargs={}) new_

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread David Cramer
I'm with Ivan. If QSRF supports everything we do + everything we want, there's no need for args (as theres no need for custom queries), but until it does, *args is very valuable, or at least a method which can do the same. On Jan 29, 1:43 pm, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]> wrote: > On 1/

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Jacob Kaplan-Moss
On 1/29/08, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > Yes, but why not have fromtuple classmethod optimized for this use- > case? And I believe this way of initialization could be really faster > than keyword initialization. I'm pretty strongly opposed to a fromtuple (or whatever) method: it's

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Ivan Illarionov
I agree that positional arguments instantiation is confusing and mixing it with keyword instantiation is even more confusing - it would be great if default Model.__init__ will be keyword argument only. But I think we still need a faster alternative. Comment in Model.__init__ states that 'nstantiat

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Tom Tobin
On 1/29/08, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > I'd make the ``*args`` style start issuing DeprecationWarnings > immediately, and remove support entirely when we wipe deprecated > features in the run-up to 1.0. I'd make this change on the > queryset-refactor branch. I'm inclined to lik

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Ivan Illarionov
> kwargs = dict([(cls._meta.fields[i].attname, v) for (i, v) in > enumerate(args)]) > > Seems like any code which explicitly needs to handle tuple > instantiation (likely the minority) can supply a helper method using > something similar to the above. Yes, but why not have fromtuple classmethod

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Marty Alchin
In the worst case, generating a kwargs dictionary from an args tuple isn't really all that difficult. kwargs = dict([(cls._meta.fields[i].attname, v) for (i, v) in enumerate(args)]) Seems like any code which explicitly needs to handle tuple instantiation (likely the minority) can supply a helper

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Ivan Illarionov
Ok I really can use Model.objects.custom_query("EXECUTE PROCEDURE ...") but someone may need more options. On 29 янв, 23:50, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > > One of the other things planned as part of qs-rf is the ability to use > > custom queries to initialize models -- something l

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Ivan Illarionov
> One of the other things planned as part of qs-rf is the ability to use > custom queries to initialize models -- something like > ``Model.objects.custom_query("SELECT ...")`` That's not enough - I need this feature to initialize models from the result of stored procedures, not just simple queries

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Jacob Kaplan-Moss
On 1/29/08, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > If you depricate this functionality please provide an alternative like > Model.fromargs() classmethod. It is extremely useful when you need to > create Model objects from custom queries. Good point. One of the other things planned as part

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Marty Alchin
On Jan 29, 2008 3:13 PM, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > Thoughts? I haven't run into any problems with this as of yet, but I'd like to wholeheartedly support this move. I was sincerely amazed when I noticed that models could be instantiated either way, and I couldn't think of a re

Re: Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Ivan Illarionov
If you depricate this functionality please provide an alternative like Model.fromargs() classmethod. It is extremely useful when you need to create Model objects from custom queries. Like here: http://code.djangoproject.com/browser/django/trunk/tests/modeltests/custom_methods/models.py in Article.

Proposal: deprecated Model.__init__(*args)

2008-01-29 Thread Jacob Kaplan-Moss
Howdy folks -- The short version: I'd like to deprecate initializing models using positional arguments (i.e. ``p = Person(1, 'Joe Somebody')``) in favor of only allowing keyword-argument initialization (i.e. ``p = Person(id=1, name='Joe Somebody')``). I'd make the ``*args`` style start issuing