Commit | Line | Data |
fc7ec1d9 |
1 | =head1 NAME |
2 | |
3 | Catalyst::Manual::Internals - Catalyst Internals |
4 | |
5 | =head1 DESCRIPTION |
6 | |
07e73f82 |
7 | This document provides an overview of the internals of |
8 | Catalyst. As Catalyst is still developing rapidly, details |
9 | may become out of date: please treat this as a guide, and |
10 | look at the source for the last word. |
fc7ec1d9 |
11 | |
5c57dc98 |
12 | The coverage is split into initialization and request lifecycle. |
13 | |
5c57dc98 |
14 | =head2 Initialization |
15 | |
16 | Catalyst initializes itself in two stages (I may be wrong in some of |
17 | the details here - AF): |
18 | |
19 | =over 4 |
20 | |
21 | =item 1 |
22 | |
07e73f82 |
23 | When the Catalyst module is imported in the main application |
24 | module it evaluates any options (C<-Debug>, C<-Engine=XXX>) |
25 | and loads any specified plugins, making the application module |
26 | inherit from the plugin classes. It also sets up a default log |
27 | object and ensures that the application module inherits from |
28 | C<Catalyst> and from the selected specialized Engine module. |
5c57dc98 |
29 | |
30 | =item 2 |
31 | |
32 | When the application module makes the first call to C<< __PACKAGE__->action() >> |
07e73f82 |
33 | (implemented in C<Catalyst::Engine>), Catalyst automatically loads all |
34 | components it finds in the C<$class::Controller>, C<$class::C>, |
35 | C<$class::Model>, C<$class::M>, C<$class::View> and C<$class::V> |
5c57dc98 |
36 | namespaces (using C<Module::Pluggable::Fast>). A table of actions is built up |
37 | and added to on subsequent calls to C<action()>. |
38 | |
39 | =back |
40 | |
41 | |
42 | =head2 Request Lifecycle |
43 | |
44 | For each request Catalyst builds a I<context> object, which includes |
07e73f82 |
45 | information about the request, and then searches the action table for matching |
5c57dc98 |
46 | actions. |
47 | |
48 | The handling of a request can be divided into three stages: preparation of the |
49 | context, processing of the request, and finalization of the response. These |
50 | are the steps of a Catalyst request in detail; every step can be overloaded to |
fc7ec1d9 |
51 | extend Catalyst. |
52 | |
53 | handler |
54 | prepare |
55 | prepare_request |
8fbcd90c |
56 | prepare_connection |
fc7ec1d9 |
57 | prepare_headers |
06e1b616 |
58 | prepare_cookies |
8fbcd90c |
59 | prepare_path |
fc7ec1d9 |
60 | prepare_action |
06e1b616 |
61 | prepare_body |
fc7ec1d9 |
62 | prepare_parameters |
63 | prepare_uploads |
16ebd349 |
64 | dispatch |
fc7ec1d9 |
65 | finalize |
16ebd349 |
66 | finalize_cookies |
fc7ec1d9 |
67 | finalize_headers |
06e1b616 |
68 | finalize_body |
fc7ec1d9 |
69 | |
5c57dc98 |
70 | These steps are normally overloaded from engine classes, and may also be |
71 | extended by plugins. Extending means using multiple inheritance with L<NEXT>. |
72 | |
73 | The specialized engine classes populate the Catalyst request object with |
74 | information from the underlying layer (C<Apache::Request> or C<CGI::Simple>) |
75 | during the prepare phase, then push the generated response information down to |
76 | the underlying layer during the finalize phase. |
77 | |
fc7ec1d9 |
78 | |
79 | =head1 AUTHOR |
80 | |
81 | Sebastian Riedel, C<sri@oook.de> |
82 | |
83 | =head1 COPYRIGHT |
84 | |
85 | This program is free software, you can redistribute it and/or modify it under |
86 | the same terms as Perl itself. |