VcRefactoring/Controller
Note: this was an experimental branch, now retired.
Following-up on the refactoring started by Peter Dimov, there's an opportunity to revive the TracDev/Proposals/ControllerApi effort.
The RequestProcessor class encapsulates all the logic for processing one specific request.
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.
Currently done:
- automatic dispatching to specific methods of the
RequestProcessorsubclass, based on theactionparameter. Those methods are nameddo_<action>for a POST request,render_<action>for a GET request andcall_<action>for an XML Http Request (also,self.xhris set toTruein the latter case). default_template,default_content_typeproperties can be set at theRequestProcessorsubclass level, so that only the data dictionary needs to be returned by a handlerdefault_stylesheets,default_javascriptsproperties can be set at theRequestProcessorsubclass level, for 'text/css' stylesheets and 'text/javascript' scripts that will always be associated to the responses.- move the matching logic at the level of the
RequestProcessoritself (add aRequestProcessor.matchclass method and aurl_patternclass property, see r5081) - reintroduced a
Controllermixin, which takes care of instantiating arequest_processorif thereq.path_infomatches - found a better name for the
call_<action>methods for handling XHRs:xhr_<action>(r5154) - r5154 enables the action handler method to easily specify the request arguments they need to use, much like the original controller branch did
TODO
- experiment with presentation objects
See also: VcRefactoring, source:sandbox/vc-refactoring@3836


