#11726: FormWizard sanity check on step number performed before dynamic steps
can
be inserted
--------------------------------------------------+-------------------------
Reporter: Eric Friesen <[email protected]> | Owner: nobody
Status: new | Milestone:
Component: django.contrib.formtools | Version: 1.1
Keywords: FormWizard | Stage: Unreviewed
Has_patch: 0 |
--------------------------------------------------+-------------------------
If you are making a FormWizard to have dynamically created steps, where
the number of steps depends on the form input of the previous steps, you
run into a problem with the sanity check inside FormWizard's
{{{__call__}}} method.
{{{
# Sanity check.
if current_step >= self.num_steps():
raise Http404('Step %s does not exist' % current_step)
# For each previous step, verify the hash and process.
# TODO: Move "hash_%d" to a method to make it configurable.
for i in range(current_step):
form = self.get_form(i, request.POST)
if request.POST.get("hash_%d" % i, '') !=
self.security_hash(request, form):
return self.render_hash_failure(request, i)
self.process_step(request, form, i)
}}}
Your cleaned_data to determine if you need to add more steps isn't
available until process_step is called on the earlier steps. However it
will never get that far because the current step will be over the number
of steps the FormWizard was initially constructed with (in the urls.py for
example).
Currently I have worked around this in my code by constructing FormWizard
with enough dummy steps that are removed and replaced with real ones just
so the formcount is always greater than the dynamic count will ever be in
the very beginning.
My proposed solution would be to do a sanity check each iteration of the
forloop ensuring that there's at least enough forms to process the next
one.
--
Ticket URL: <http://code.djangoproject.com/ticket/11726>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---