* David MENTRE <[email protected]> [2010-06-21 11:51:58]:

> > +    form = forms.MapSearchForm(request.GET)
> > +
> > +    if form.is_valid():
> > +        map_list = (models.MapRenderingJob.objects
> > +                    .order_by('maptitle')
> > +                    .filter(status=2)
> > +                    
> > .filter(maptitle__icontains=form.cleaned_data['query']))
> > +        if len(map_list) == 1:
> > +            return HttpResponseRedirect(reverse('job-by-id',
> > +                                                args=[map_list[0].id]))
> 
> On this patch you do not test "if request.method == 'GET':". Can I
> assume this code is not necessary?

Regardless of the request method (GET/POST), the code gracefully handles
the case where the GET query parameter is not provided (the form simply
doesn't validate). So it's not really useful to test for the request
method and add a level of indent here.

- Maxime, who helped Maxime² on this
-- 
Maxime Petazzoni <http://www.bulix.org>
 ``One by one, the penguins took away my sanity.''
Linux kernel and software developer at MontaVista Software

Attachment: signature.asc
Description: Digital signature

Reply via email to