Opened 13 years ago
Closed 13 years ago
#18751 closed Cleanup/optimization (fixed)
`BaseFormSet._should_delete_form` should use `form.cleaned_data`
| Reported by: | Simon Charette | Owned by: | nobody | 
|---|---|---|---|
| Component: | Forms | Version: | dev | 
| Severity: | Normal | Keywords: | formset | 
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | yes | UI/UX: | no | 
Description
Attachments (4)
Change History (10)
by , 13 years ago
| Attachment: | ticket-18751.0.diff added | 
|---|
comment:1 by , 13 years ago
| Has patch: | set | 
|---|
by , 13 years ago
| Attachment: | ticket-18751.1.diff added | 
|---|
comment:2 by , 13 years ago
Added a new patch that fixes a bogus testcase which was saving a formset before making sure it was valid.
comment:3 by , 13 years ago
| Triage Stage: | Unreviewed → Accepted | 
|---|
Interestingly, I have uploaded a similar patch to #10711 (https://code.djangoproject.com/attachment/ticket/10711/10711-2.diff). I will close it in favour of this one. Maybe there is something to merge between both patches?
by , 13 years ago
| Attachment: | ticket-18751.2.diff added | 
|---|
comment:4 by , 13 years ago
Your patch looks better thank mines since you don't have to change the test suite and you reuse the deleted_forms code path.
by , 13 years ago
| Attachment: | 10711-2.diff added | 
|---|
claudep's patch for #10711 which happens to fix this issue
comment:5 by , 13 years ago
| Triage Stage: | Accepted → Ready for checkin | 
|---|
claudep, I'm marking the patch you've written for #10711 as RFC since it passes all tests (python 2.7.3rc1 sqlite3) and is the definitive way to clean up _should_delete_form with backward compatibility in mind. My patches we're incomplete since they introduced an obscure raises of AttributeError when attempting to save a not-yet-validated formset (which is a foolish thing to do anyway), see ticket-18751.2.diff testsuite changes.
comment:6 by , 13 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
All tests pass on python 2.7.3rc1 sqlite3. I'm wondering if we shouldn't add and accessor for
Form.cleaned_datathat would call trigger validation under the hood, the same wayForm.errorsdoes. We could still raise anAttributeErrorifform.is_bound() == False: