Fix mysterious scope loss of a radio button callback in rb-site wizard
Review Request #2374 — Created May 18, 2011 and submitted
As a student of GSoC'11 I got my first task was to install RB and fix trivial bug. During installation I ran rb-site and noticed strange behavior of the setup wizard. Namely, it didn't remember my choice of caching method and still tried to ask about memcached server location. Investigation the reason of this behavior I found out that the user choice wasn't actually stored as the button callback function lost its scope and hence coulnd't find the object to write. As the result each time I toggled a radio button I got Traceback (most recent call last): File "/home/mbait/src/reviewboard/reviewboard/cmdline/rbsite.py", line 1044, in on_toggled setattr(save_obj, save_var, valid_choices[radio_button]) NameError: free variable 'save_obj' referenced before assignment in enclosing scope Incidentally I fixed some other possible corner case related errors
Manual testing
-
-
Blank line between these. There should generally be a blank line between blocks of code (such as if statements).
-
You can do: first_enabled += 1 What happens if we three radio buttons, the first of which is enabled and the others which are not? First_enabled is going to end up being 2. Probably not what we want.
-
-
MB
- Change Summary:
-
- added some blank lines between logical blocks - fixed strategy of calculation the first enabled button
- Diff:
-
Revision 2 (+15 -9)