[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Maposmatic-dev] debugging empty floats in /apis/papersize/

From: David MENTRE
Subject: [Maposmatic-dev] debugging empty floats in /apis/papersize/
Date: Sat, 21 Apr 2012 14:58:47 +0200


I looked at the issue of /apis/papersize/ when sometimes we get a
float conversion error.

To trigger the bug, I copy/paste following test after a "telnet
localhost 8000" (any simpler way to do that?):
POST /apis/papersize/ HTTP/1.1



It appears that in www/maposmatic/, code
                lat_upper_left = f.cleaned_data.get("lat_upper_left")
                lon_upper_left = f.cleaned_data.get("lon_upper_left")
                lat_bottom_right = f.cleaned_data.get("lat_bottom_right")
                lon_bottom_right = f.cleaned_data.get("lon_bottom_right")
is not protected into invalid float value (empty string, not a float string).

Is there a proper way to tell Django that the four values should be
valid float numbers?

My current approach would be to catch the "TypeError" exception and
return HttpResponseBadRequest("ERROR: Invalid arguments") in that
case. Does it seem correct to you? Any suggestion to fix this issue in
a more Django-ic or Pythonic way?

BTW, it does not fix the real issue (i.e. why do we have empty string
for float values), but at least we should return a proper error code
and not have an internal error in that case.

Best regards,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]