Re: Proposal for prepared statements API

2014-03-26 Thread Anssi Kääriäinen
On 03/26/2014 06:06 AM, Curtis Maloney wrote: Further, as an "expert" feature, would it be unreasonable to limit its use to cases where you know it will benefit, but also only be used in a single connection? True, this limits its use cases somewhat, but it's sti

Re: Add support for get_or_none?

2014-03-26 Thread Anssi Kääriäinen
I'd like to solve this with a way to add methods to QuerySets. This would be useful for those who want get_or_none() or other similar shortcut methods which Django doesn't provide. But more importantly this would let third party apps to provide queryset methods. If this was possible, then one

Re: Add support for get_or_none?

2014-03-26 Thread Russell Keith-Magee
On Wed, Mar 26, 2014 at 4:26 PM, Anssi Kääriäinen wrote: > I'd like to solve this with a way to add methods to QuerySets. This > would be useful for those who want get_or_none() or other similar shortcut > methods which Django doesn't provide. But more importantly this would let > third party app

Re: Add support for get_or_none?

2014-03-26 Thread Anssi Kääriäinen
On 03/26/2014 10:46 AM, Russell Keith-Magee wrote: Isn't this already possible by defining a custom queryset? And even easier in 1.7 with the introduction of .as_manager()? The only thing the custom Queryset approach doesn't allow is to monkey patch the get_or_none method into *all* managers b

Re: Add support for get_or_none?

2014-03-26 Thread Curtis Maloney
You could (ab)use MethodType to add a new method to the class, but you'd want to make sure the Manager was using a custom QuerySet first [or force it to if it weren't] so as not to alter it for all default Managers. Just my 0.02 units of currency. -- C On 26 March 2014 19:26, Anssi Kääriäinen

Re: Migrations in Django 1.7 make unit testing models harder

2014-03-26 Thread Bernie Sumption
> > we can't promote adding random strings to MIGRATION_MODULES as the > suggested way to "get around" migrations for tests. > I agree, my workaround is a hack. It would be better to introduce a flag or setting designed specifically for this use case. > In my opinion, the whole point of migr

Re: [GSOC] Introduction and task proposal

2014-03-26 Thread Daniel Pyrathon
Hi all, It's been a while since I submitted my GSOC proposal. Although I am currently under exams, is there anything you would recommend me to do at this point (other than hope that my proposal is successful)? Thanks, Daniel Pyrathon On Thursday, March 20, 2014 6:05:40 AM UTC, Russell Keith-Ma

Re: Add support for get_or_none?

2014-03-26 Thread Cal Leeming [Simplicity Media Ltd]
On Tue, Mar 25, 2014 at 11:40 PM, Russell Keith-Magee < russ...@keith-magee.com> wrote: > > On Thu, Mar 20, 2014 at 9:31 PM, Florian Apolloner > wrote: > >> On Thursday, March 20, 2014 2:01:25 PM UTC+1, Cal Leeming [Simplicity >> Media Ltd] wrote: >>> >>> I'll give it a couple more days for a BDF

Re: Proposal for prepared statements API

2014-03-26 Thread Aymeric Augustin
2014-03-26 9:16 GMT+01:00 Anssi Kääriäinen : > We can do this by having a map of SQL for the statement -> name of the > prepared statement in the connection. On connection close the known > statements are cleaned. Yes, that seems correct. Since prepared statements are connection-local, it makes

Re: Add support for get_or_none?

2014-03-26 Thread Wim Feijen
Hi Cal, When we proposed to add get_or_none() , we actually ended up adding a first() -method. The primary motives were to have a clearer name and to stay in line with other existing api's. In my opinion, get_or_none is too much a duplicate of first and I am therefore -1 of it being added. F

Re: Migrations in Django 1.7 make unit testing models harder

2014-03-26 Thread Andrew Godwin
When I practice TDD I write the test to spec, and then write the model and view code, so I usually have about the same amount of model changes as otherwise (as, having written the tests, I usually have a clearer idea of what fields I need). I agree that if you're incrementally writing tests on top

Re: Add support for get_or_none?

2014-03-26 Thread Paulo Poiati
Well, I think this kind of feature is in the same category of my request:  https://groups.google.com/forum/#!topic/django-developers/N6xazCaJC_E. I haven’t received so many feedbacks though. It’s all about writing less code to reach the goal. I belive too much abstraction is not a good thing for

Re: Using namedtuple instead of pure tuples

2014-03-26 Thread Adam Kaliński
Hi, I improved my benchmarks: http://nbviewer.ipython.org/gist/adamkal/9171081 Alex was right about those variables and new benchmarks have proved it. I also created a draft of how it might look like for Options.get_field_by_name (as this returns 4-tuple): https://github.com/adamkal/django/co

Re: [GSOC] Introduction and task proposal

2014-03-26 Thread Russell Keith-Magee
Hi Daniel, Nope - other than "cross your fingers" that your proposal is accepted :-) But seriously... If you haven't already, I'd suggest reading Django's contribution docs, and getting your development environment set up. Make sure you can run Django's test suite. If you're particularly enthuse

Re: Add support for get_or_none?

2014-03-26 Thread Russell Keith-Magee
On Wed, Mar 26, 2014 at 8:19 PM, Cal Leeming [Simplicity Media Ltd] < cal.leem...@simplicitymedialtd.co.uk> wrote: > > > > On Tue, Mar 25, 2014 at 11:40 PM, Russell Keith-Magee < > russ...@keith-magee.com> wrote: > >> >> On Thu, Mar 20, 2014 at 9:31 PM, Florian Apolloner > > wrote: >> >>> On Thurs

Re: Add support for get_or_none?

2014-03-26 Thread Anssi Kääriäinen
On Thursday, March 27, 2014 3:10:13 AM UTC+2, Russell Keith-Magee wrote: > > In my ideal world, the get(default=None) approach would be what we would > do; but, as others have pointed out, default is a valid column name, so > this option isn't available to us. We already have a shortcut for > ge

Re: [GSOC] Introduction and task proposal

2014-03-26 Thread Josh Smeaton
If you haven't already got all your databases installed on your development machine, I *highly* recommend checking out https://github.com/jphalip/djangocore-box. It's a vagrant VM environment that already has MySQL, PostgreSQL, and SQLite installed (plus most GIS installations), along with vari