Hands-On Enterprise Application Development with Python
上QQ阅读APP看书,第一时间看更新

Controller

The controller acts as an intermediary between the model and the view. When a request is first made to the application, the controller intercepts the request and, based on that, decides which model and views need to be called. Once this is decided, the controller then executes the model to run the business logic, retrieving the data from the model. Once the data has been retrieved and model execution has been finished, the controller then executes the view with the data that is gathered from the model. Once the view execution is finished, the user sees a response from the view.

In a brief, the controller is responsible for doing the following operations:

  • Intercepting the requests made to the application, and executing the required models and views based on that
  • Manipulating the view when the model changes
  • Manipulating the model based on interaction of the user with the view