stop using MethodViews in flask apps
Closed this issue · 3 comments
Plain functions are just fine.
(Imported from https://bugzilla.mozilla.org/show_bug.cgi?id=1508137, filed by @allan-silva)
@bhearsum I have some clarifying questions for this issue.
- Does this mean that in a function such as:
balrog/src/auslib/web/admin/emergency_shutoff.py
Lines 48 to 50 in ab3882c
Instead we would have the get function that is in the ScheduledChangeView:
balrog/src/auslib/web/admin/views/scheduled_changes.py
Lines 61 to 73 in ab3882c
- How would we deal with the base views that the views inherit from i.e. AdminView and HistoryView
To answer the second question first -- any code that is shared by multiple views would need to be refactored to be a plain function (not a class method), which the new view functions could then call. This is actually what is already happening in emergency_shutoffs.py
. It is not happening in files like
(This code is connected to an endpoint name through
balrog/src/auslib/web/admin/swagger/api.yml
Line 1990 in ab3882c
@bhearsum Thank you for the detailed explanation on my second question. After going through the linked files again, I now understand how plain functions would work as the base in place of the base views.