doc/book/devweb/publisher.rst
changeset 10491 c67bcee93248
parent 5400 b7ab099b128a
child 12530 9d88e1177c35
equal deleted inserted replaced
10490:76ab3c71aff2 10491:c67bcee93248
       
     1 .. _publisher:
       
     2 
       
     3 Publisher
       
     4 ---------
       
     5 
       
     6 What happens when an HTTP request is issued ?
       
     7 
       
     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 .. _`twisted`: http://twistedmatrix.com/trac/
       
    15 
       
    16 What main_publish does:
       
    17 
       
    18 * get a controller id and a result set from the path (this is actually
       
    19   delegated to the `urlpublisher` component)
       
    20 
       
    21 * the controller is then selected (if not, this is considered an
       
    22   authorization failure and signaled as such) and called
       
    23 
       
    24 * then either a proper result is returned, in which case the
       
    25   request/connection object issues a ``commit`` and returns the result
       
    26 
       
    27 * or error handling must happen:
       
    28 
       
    29   * ``ValidationErrors`` pop up there and may lead to a redirect to a
       
    30     previously arranged url or standard error handling applies
       
    31   * an HTTP 500 error (`Internal Server Error`) is issued
       
    32 
       
    33 
       
    34 Now, let's turn to the controller. There are many of them in
       
    35 :mod:`cubicweb.web.views.basecontrollers`. We can just follow the
       
    36 default `view` controller that is selected on a `view` path. See the
       
    37 :ref:`controllers` chapter for more information on controllers.
       
    38 
       
    39 The `View` controller's entry point is the `publish` method. It does
       
    40 the following:
       
    41 
       
    42 * compute the `main` view to be applied, using either the given result
       
    43   set or building one from a user provided rql string (`rql` and `vid`
       
    44   can be forced from the url GET parameters), that is:
       
    45 
       
    46     * compute the `vid` using the result set and the schema (see
       
    47       `cubicweb.web.views.vid_from_rset`)
       
    48     * handle all error cases that could happen in this phase
       
    49 
       
    50 * do some cache management chores
       
    51 
       
    52 * select a main template (typically `TheMainTemplate`, see chapter
       
    53   :ref:`templates`)
       
    54 
       
    55 * call it with the result set and the computed view.
       
    56 
       
    57 What happens next actually depends on the template and the view, but
       
    58 in general this is the rendering phase.
       
    59 
       
    60 
       
    61 CubicWebPublisher API
       
    62 `````````````````````
       
    63 
       
    64 .. autoclass:: cubicweb.web.application.CubicWebPublisher
       
    65    :members: