Code

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#11806 closed (duplicate)

FormWizard.process_step() doesn't always have a validated Form.

Reported by: kiowa Owned by: nobody
Component: Documentation Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The FormWizard documentation says:

FormWizard.process_step()

    Hook for modifying the wizard's internal state, given a fully validated Form object. The Form is guaranteed to have clean, valid data.

But the form isn't always guaranteed to be clean - and thus give access to its cleaned_data mapping.

To achieve this you will need in your process_step:

process_step(self, request, form, step):
    form.full_clean()

Attachments (0)

Change History (5)

comment:1 Changed 5 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

You've stated that the form isn't always guaranteed to be clean without providing an example of how that could happen. Based on the documentation and a brief look at the code, that happening would seem to be a coding error rather than a documentation problem. So as written I believe this ticket is invalid. Feel free to reopen with specifics on how to recreate a situation where process_step is called without a valid form, but the place to look for fixing it I believe will be in the code, not the documentation.

comment:2 follow-up: Changed 5 years ago by mpaolini

  • Resolution invalid deleted
  • Status changed from closed to reopened

in contrib/formtools/wizard.py

63 	        for i in range(current_step):
64 	            form = self.get_form(i, request.POST)
65 	            if request.POST.get("hash_%d" % i, '') != self.security_hash(request, form):
66 	                return self.render_hash_failure(request, i)
67 	            self.process_step(request, form, i)

line 67: form passed to self.process_step is _never_ cleaned (happens for all forms before current_step)

this is an old bug, I'm sure there are other tickets on this

comment:3 in reply to: ↑ 2 ; follow-up: Changed 5 years ago by kmtracey

  • Resolution set to duplicate
  • Status changed from reopened to closed

Replying to mpaolini:

this is an old bug, I'm sure there are other tickets on this

If you believed that then why did you not search for existing tickets? Which would have brought up #10882. We don't need multiple tickets for the same problem.

comment:4 in reply to: ↑ 3 Changed 5 years ago by anonymous

Replying to kmtracey:

If you believed that then why did you not search for existing tickets? Which would have brought up #10882. We don't need multiple tickets for the same problem.

Ok my fault, please forgive me and commit the (3 months old) patch in #10882

comment:5 Changed 5 years ago by mpaolini

previous comment was mine

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.