Version 1 (modified by 17 years ago) ( diff ) | ,
---|
VcRefactoring/Controller
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.
Work in progress
Currently done:
- automatic dispatching to specific methods of the
RequestProcessor
subclass, based on theaction
parameter. Those methods are nameddo_<action>
for a POST request,render_<action>
for a GET request andcall_<action>
for an XML Http Request (also,self.xhr
is set toTrue
in the latter case). default_template
,default_content_type
properties can be set at theRequestProcessor
subclass level, so that only the data dictionary needs to be returned by a handlerdefault_stylesheets
,default_javascripts
properties can be set at theRequestProcessor
subclass level, for 'text/css' stylesheets and 'text/javascript' scripts that will always be associated to the responses.
TODO
- move the matching logic at the level of the
RequestProcessor
itself - find a better name for the
call_<action>
methods for handling XHRs (the default XHR handler is namedcall_view
which doesn't look good)
See also: VcRefactoring, source:sandbox/vc-refactoring