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