-
-
Notifications
You must be signed in to change notification settings - Fork 145
Fix infinite recursion error #220 #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This removes the undocumented `get_form_list` since the process of repeatedly and dynamically generating an OrderedDict of steps/forms pairs leads to infinite recursion. This is replaced with a new method `process_condition_dict` which directly modifies `form_list` in place, in a single step executed prior to dispatching to `get` or `post`. This eliminates infinite recursion since the `form_list` is calculated exactly once prior to any other attempts to access and process forms. Removed `test_form_condition_unstable` since this is an odd test (why would a condition_dict return value suddenly change in the middle of a request/response cycle?) that was attempting to deal with invalid steps (invalid steps are better handled through actual validation, see jazzband#224). For users who need to dynamically _add_ forms, this can be handled by overriding `process_condition_dict`.
@schinckel Do you have an opinion on this approach? |
Codecov Report
@@ Coverage Diff @@
## master #228 +/- ##
==========================================
- Coverage 93.88% 92.69% -1.19%
==========================================
Files 10 10
Lines 523 520 -3
Branches 66 66
==========================================
- Hits 491 482 -9
- Misses 19 21 +2
- Partials 13 17 +4
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I’ll oppose this change, since there is no way to add additional forms using it: that’s my primary reason for the initial change; I have a for that may need to be repeated N times based on a previous form’s cleaned data. |
OK, thanks, let this PR aside for now. Thanks anyway @jsma for proposing it. |
(Just saw this was closed while writing this reply) FYI, I'm still testing this branch in a project with several different wizards with varying customizations. I'm currently getting odd test failures for one wizard where my test suite fails when run as a suite but passes when a specific test method is run. All of my other wizards are working just fine. I'll try to get to the bottom of this shortly to determine whether it's simply an issue with how my tests are written or if it's a problem of when/where this PR prunes The bug I'm trying to fix was due to a feature enhancement that broke documented uses cases (checking cleaned data in a condition). From my perspective, new features should not break existing, documented functionality. Unfortunately the 2.4 release did not do this. Software is hard and I'm not here to criticize anyone. The reality is that 2.4 is a release that introduces infinite recursion errors and needs to be fixed one way or another ASAP. Reverting the change is one quick option while we think this through a bit more, but this PR was an attempt to restore existing functionality while still making it possible to inject additional forms. What about this PR prevents you from adding forms? I tried to leave this option open, but perhaps I failed. That is why I was soliciting feedback specifically from folks who are trying to add forms that are not initially present in In my project, the subclass customizations either use As far as I can tell, django-formtools/formtools/wizard/views.py Lines 294 to 306 in 3eb4a43
|
FYI, I totally goofed in this initial draft, it modified the |
This removes the undocumented
get_form_list
since the process of repeatedly and dynamically generating an OrderedDict of steps/forms pairs leads to infinite recursion. This is replaced with a new methodprocess_condition_dict
which directly modifiesform_list
in place, in a single step executed prior to dispatching toget
orpost
. This eliminates infinite recursion since theform_list
is calculated exactly once prior to any other attempts to access and process forms.Removed
test_form_condition_unstable
since this is an odd test (why would a condition_dict return value suddenly change in the middle of a request/response cycle?) that was attempting to deal with invalid steps (invalid steps are better handled through actual validation, see #224).For users who need to dynamically add forms, this can be handled by overriding
process_condition_dict
.