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: preventing syncdb from loading initial_data

2008-01-29 Thread Russell Keith-Magee
On Jan 30, 2008 8:17 AM, Joseph Kocherhans <[EMAIL PROTECTED]> wrote: > > I ran into a situation today where for every future site I set up, > I'll want to load an initial_data fixture, but for some existing sites > that I'm upgrading, it's very useful to be able to run syncdb without > loading an

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_

preventing syncdb from loading initial_data

2008-01-29 Thread Joseph Kocherhans
I ran into a situation today where for every future site I set up, I'll want to load an initial_data fixture, but for some existing sites that I'm upgrading, it's very useful to be able to run syncdb without loading any fixtures. Thus http://code.djangoproject.com/ticket/6511 I'll write up the do

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.

Re: #django registration

2008-01-29 Thread Collin Grady
Jeremy Dunck said the following: > On Dec 28, 2007 11:35 AM, Adrian Holovaty <[EMAIL PROTECTED]> wrote: >> I'm happy to take care of this -- I just don't know what's involved in >> registering a channel. Could you provide some more information on whom >> to talk to about getting it done? > > http

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

Re: BaseHandler

2008-01-29 Thread Jacob Kaplan-Moss
On 1/28/08, Bryan McLemore <[EMAIL PROTECTED]> wrote: > I'm more looking for discussion. Feedback on what I've said and on > the implementation if people are so inclined. I'm not done yet by > far, so making an official patch submission would be premature. The problem is that reading patches in

Re: Unicode usernames?

2008-01-29 Thread Ivan Illarionov
There are a lot of good reasons to have username ascii-only 1. You may want to login to your site from non-national keyboard/OS 2. URLs with unicode characters look ugly 3. Paths and filenames may be broken 4. It's not hard to transliterate your real name with ascii-only letters --~--~-~--

Re: Unicode usernames?

2008-01-29 Thread Ivan Illarionov
No! Unicode usernames is a bad idea. Usernames can be used for URLs, paths and other technical stuff. Unicode usernames is a source of unlimited potential bugs. It might be a good idea to add the unicode 'nickname' field that can be used instead of username in views - and still use 'username' for