Monday, December 30, 2019

lesson learned for model-view-controller: form workflows

Model-view-controller (MVC) is a way to separate presentation from the backend computation and data transformation.

For my application, "model" = compute.py; "view" = a collection of webpages; "controller" = controller.py

MVC nuances with Flask and WTForms --

  • The business logic workflow is captured exclusively in controller.py
  • Upon form submission the workflow should return back to controller.py rather than linking to next page. The controller.py uses redirect(url_for()) to transition between pages.
  • Form data extraction occurs in the controller; manipulations to the form data are made in compute.py (the model). 

No comments:

Post a Comment