doc/book/en/development/devweb/publisher.rst
branchstable
changeset 5301 f4219a6e62e3
parent 5284 ad922b7449aa
child 5348 db7b4d2eba4b
equal deleted inserted replaced
5300:058db99425e4 5301:f4219a6e62e3
     1 .. _publisher:
     1 .. _publisher:
     2 
     2 
     3 Publisher
     3 Publisher
     4 ---------
     4 ---------
     5 
     5 
     6 XXX view.vid_from_rset
     6 What happens when an HTTP request is issued ?
     7 
     7 
     8 XXX cubicweb.web.application; coop diagram for execution of a http query
     8 The story begins with the ``CubicWebPublisher.main_publish``
       
     9 method. We do not get upper in the bootstrap process because it is
       
    10 dependant on the used HTTP library. With `twisted`_ however,
       
    11 ``cubicweb.etwist.server.CubicWebRootResource.render_request`` is the
       
    12 real entry point.
       
    13 
       
    14 What main_publish does:
       
    15 
       
    16 * get a controller id and a result set from the path (this is actually
       
    17   delegated to the `urlpublisher` component)
       
    18 
       
    19 * the controller is then selected (if not, this is considered an
       
    20   authorization failure and signaled as sich) and called
       
    21 
       
    22 * then either a proper result is returned, in which case the
       
    23   request/connection object issues a ``commit`` and returns the result
       
    24 
       
    25 * or error handling must happen:
       
    26 
       
    27   * ``ValidationErrors`` pop up there and may lead to a redirect to a
       
    28     previously arranged url or standard error handling applies
       
    29   * an HTTP 500 error (`Internal Server Error`) is issued
       
    30 
       
    31 
       
    32 Now, let's turn to the controller. There are many of them in
       
    33 :mod:`cubicweb.web.views.basecontrollers`. We can just follow the
       
    34 default `view` controller that is selected on a `view` path. See the
       
    35 :ref:`controllers` chapter for more information on controllers.
       
    36 
       
    37 The `View` controller's entry point is the `publish` method. It does
       
    38 the following:
       
    39 
       
    40 * compute the `main` view to be applied, using either the given result
       
    41   set or building one from a user provided rql string (`rql` and `vid`
       
    42   can be forced from the url GET parameters), that is:
       
    43 
       
    44     * compute the `vid` using the result set and the schema (see
       
    45       `cubicweb.web.views.vid_from_rst`)
       
    46     * handle all error cases that could happen in this phase
       
    47 
       
    48 * do some cache management chores
       
    49 
       
    50 * select a main template (typically `TheMainTemplate`, see chapter
       
    51   :ref:`templates`)
       
    52 
       
    53 * call it with the result set and the computed view.
       
    54 
       
    55 What happens next actually depends on the template and the view, but
       
    56 in general this is the rendering phase.
       
    57 
       
    58 
       
    59 CubicWebPublisher API
       
    60 `````````````````````
       
    61 
       
    62 .. autoclass:: cubicweb.web.application.CubicWebPublisher
       
    63    :members: