Re: proposal: ask a queryset to not raise exceptions

2010-03-07 Thread David Cramer
I definitely would like to see this handled in Django, but not in the way mentioned. I personally think there does not need to be an option for what it raises. I think of this in the situations where find methods return either a -1, or an Exception, based on which method you call. Now I can't

Re: proposal: ask a queryset to not raise exceptions

2010-03-07 Thread Vitaliy Kulchevych
http://code.djangoproject.com/ticket/5741 On Sun, Mar 7, 2010 at 11:48 PM, Chris wrote: > In my projects, I use this pattern a lot: > > try: >    obj = SomeModel.objects.filter(**crazy_filters_here).latest() > except SomeModel.DoesNotExist: >    obj = None > > Basically, I

values() and values_list() for RawQuerySet?

2010-03-07 Thread Boris Schaeling
The new raw() manager method in version 1.2 is a great addition. However as flexible as the SQL code can be passed to raw() the RawQuerySet object returned is unfortunately not very flexible. There has been __getitem__() added two weeks ago but apart from that you still can only iterate over

Re: Allowing models to influence QuerySet.update

2010-03-07 Thread Dennis Kaarsemaker
On ma, 2010-03-08 at 08:09 +0800, Russell Keith-Magee wrote: > On Mon, Mar 8, 2010 at 7:56 AM, Dennis Kaarsemaker > wrote: > > I have now added tests and documentation. Comments are still welcome, I > > have not received any feedback yet :( > > Please don't take it

Re: Allowing models to influence QuerySet.update

2010-03-07 Thread Russell Keith-Magee
On Mon, Mar 8, 2010 at 7:56 AM, Dennis Kaarsemaker wrote: > I have now added tests and documentation. Comments are still welcome, I > have not received any feedback yet :( Please don't take it personally -- it's just that we're just not really fielding new features at the

Re: proposal: ask a queryset to not raise exceptions

2010-03-07 Thread Taylor Marshall
> PS: Can people *please* use 'cls' and not 'klass'. =/ Yes you are right, my fault. Although I did just rip the code from the patch at http://code.djangoproject.com/ticket/2659 and modify it. Additionally, looking at that issue will likely give some insight into the response this change will

Re: Allowing models to influence QuerySet.update

2010-03-07 Thread Dennis Kaarsemaker
I have now added tests and documentation. Comments are still welcome, I have not received any feedback yet :( On wo, 2010-03-03 at 19:00 +0100, Dennis Kaarsemaker wrote: > I know that queryset.update does not call .save() for each instance and > I know why. I even agree with it :) > > However,

Re: Would a "Feedback" triage stage be helpful?

2010-03-07 Thread Russell Keith-Magee
On Sun, Mar 7, 2010 at 5:27 AM, Gabriel Hurley wrote: > I'm certainly not discouraged and I appreciate the reply. The > crowdsourced/trust-based system is more what I had in mind; my > suggestion was trying to shoehorn that thought into the existing > tracker. > > Given that I

Re: proposal: ask a queryset to not raise exceptions

2010-03-07 Thread Jerome Leclanche
A couple of things: * Technically, a queryset doesn't raise DoesNotExist; a model does. When you call latest(), you call the latest model in the queryset, which, in the case of an empty qs, raises DoesNotExist * (bite me) I work with lossy data and very often have to deal with broken relations.

Re: Potential GSoC 2010 Student

2010-03-07 Thread Russell Keith-Magee
On Mon, Mar 8, 2010 at 12:13 AM, Tyler Laing wrote: > Hello all! > > I am interested in contributing to Django over GSoC 2010. > > A quick introduction is in order. I am currently a 4th year Computer > Science student in a BSc. at UBC, Okanagan campus. > > I am quite fluent

Re: proposal: ask a queryset to not raise exceptions

2010-03-07 Thread Taylor Marshall
Seems like it'd be pretty simple for the developer to make a little helper method like so... >>> def latest_or_none(klass, *args, **kwargs): >>> try: >>> return klass.objects.filter(*args, **kwargs).latest() >>> except klass.DoesNotExist: >>> return None I guess I don't

Re: proposal: ask a queryset to not raise exceptions

2010-03-07 Thread Will Hardy
I'm not sure what reception you'll get for this suggestion (also given that all attention is currently on Django 1.2), but I think eventually problems like these may be best addressed by allowing you as the developer to write your own customised helper functions/methods to deal with things the way

proposal: ask a queryset to not raise exceptions

2010-03-07 Thread Chris
In my projects, I use this pattern a lot: try: obj = SomeModel.objects.filter(**crazy_filters_here).latest() except SomeModel.DoesNotExist: obj = None Basically, I throw a filter at a queryset and if some value comes out, I use it, If the filter happens to filter out all rows, I want the