What happens when an HTTP request is issued ?
The story begins with the CubicWebPublisher.main_publish method. We do not get upper in the bootstrap process because it is dependant on the used HTTP library. With twisted however, cubicweb.etwist.server.CubicWebRootResource.render_request is the real entry point.
What main_publish does:
Now, let’s turn to the controller. There are many of them in cubicweb.web.views.basecontrollers. We can just follow the default view controller that is selected on a view path. See the Controllers chapter for more information on controllers.
The View controller’s entry point is the publish method. It does the following:
compute the main view to be applied, using either the given result set or building one from a user provided rql string (rql and vid can be forced from the url GET parameters), that is:
- compute the vid using the result set and the schema (see cubicweb.web.views.vid_from_rset)
- handle all error cases that could happen in this phase
do some cache management chores
select a main template (typically TheMainTemplate, see chapter Templates)
call it with the result set and the computed view.
What happens next actually depends on the template and the view, but in general this is the rendering phase.
the publisher is a singleton hold by the web frontend, and is responsible to publish HTTP request.
The http server will call its main entry point application.handle_request.
Process an http request
Arguments are: - a Request object - path of the request object
It returns the content of the http response. HTTP header and status are set on the Request object.
You have to provide both a repository and web-server config at initialization. In all in one instance both config will be the same.
method called by the main publisher to process <path>
should return a string containing the resulting page or raise a NotFound exception
Parameters: |
|
---|---|
Return type: | str |
Returns: | the result of the pusblished url |
Log ‘msg % args’ with severity ‘CRITICAL’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.critical(“Houston, we have a %s”, “major disaster”, exc_info=1)
Log ‘msg % args’ with severity ‘DEBUG’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.debug(“Houston, we have a %s”, “thorny problem”, exc_info=1)
Log ‘msg % args’ with severity ‘ERROR’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.error(“Houston, we have a %s”, “major problem”, exc_info=1)
Convenience method for logging an ERROR with exception information.
Return a session object corresponding to credentials held by the req
May raise AuthenticationError.
Log ‘msg % args’ with severity ‘INFO’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.info(“Houston, we have a %s”, “interesting problem”, exc_info=1)
wrapper around _publish to log all queries executed for a given accessed path
Process an http request
Arguments are: - a Request object - path of the request object
It returns the content of the http response. HTTP header and status are set on the Request object.
handle redirect - comply to ex status - set header field - return empty content
Log ‘msg % args’ with severity ‘WARNING’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.warning(“Houston, we have a %s”, “bit of a problem”, exc_info=1)