Fixed form cleaning behavior upon error

When an error occurs while processing the form's data, cleaning up the
data can result in attempting to delete non existent keys. This patch
should make the code tolerant to the half-created form data we have to
deal with in that case.

The problem happened 5 or 6 times within the last 3 weeks.
stable
David Decotigny 2010-09-19 12:40:17 +02:00
rodzic 8bb5fcd5da
commit 0f7fccd868
1 zmienionych plików z 3 dodań i 2 usunięć

Wyświetl plik

@ -112,7 +112,8 @@ class MapRenderingJobForm(forms.ModelForm):
if val is None:
msg = _(u"Required")
self._errors['bbox'] = forms.util.ErrorList([msg])
del cleaned_data[f]
if f in cleaned_data:
del cleaned_data[f]
# Make sure that bbox and admin modes are exclusive
cleaned_data["administrative_city"] = ''
@ -121,7 +122,7 @@ class MapRenderingJobForm(forms.ModelForm):
# Don't try to instanciate a bounding box with empty coordinates
if self._errors:
return cleaned_data
lat_upper_left = cleaned_data.get("lat_upper_left")
lon_upper_left = cleaned_data.get("lon_upper_left")
lat_bottom_right = cleaned_data.get("lat_bottom_right")