| 1 | = VcRefactoring/Controller = |
| 2 | |
| 3 | Following-up on the [googlegroups:trac-dev:b08a7132c7d76fd8 refactoring started by Peter Dimov], there's an opportunity to revive the TracDev/Proposals/ControllerApi effort. |
| 4 | |
| 5 | The `RequestProcessor` class encapsulates all the logic for processing one specific request. |
| 6 | It was therefore natural to extend it with the response helpers and the dispatching logic that was previously attached to the proposed Controller class. As that class was a Component mixin, it was not convenient to keep Request related state at that level. |
| 7 | |
| 8 | ''Work in progress'' |
| 9 | |
| 10 | Currently done: |
| 11 | - automatic dispatching to specific methods of the `RequestProcessor` subclass, based on the `action` parameter. Those methods are named `do_<action>` for a POST request, `render_<action>` for a GET request and `call_<action>` for an [wikipedia:XMLHttpRequest XML Http Request] (also, `self.xhr` is set to `True` in the latter case). |
| 12 | - `default_template`, `default_content_type` properties can be set at the `RequestProcessor` subclass level, so that only the data dictionary needs to be returned by a handler |
| 13 | - `default_stylesheets`, `default_javascripts` properties can be set at the `RequestProcessor` subclass level, for 'text/css' stylesheets and 'text/javascript' scripts that will always be associated to the responses. |
| 14 | |
| 15 | TODO: |
| 16 | - move the matching logic at the level of the `RequestProcessor` itself |
| 17 | - find a better name for the `call_<action>` methods for handling XHRs (the default XHR handler is named `call_view` which doesn't look good) |
| 18 | |
| 19 | ---- |
| 20 | See also: VcRefactoring, source:sandbox/vc-refactoring |