X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FCatalystBasics.pod;h=0a7daa58431b466500c8a63b93dddce83a926929;hb=8112f93129b5c90c215ac22135b1172ed710a125;hp=32388a37ef86019b3b7ee34e50bbab1e6298b41e;hpb=586b6141d5d4fd8bea38d71e70dab2af3579314f;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod b/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod index 32388a3..0a7daa5 100644 --- a/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod +++ b/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod @@ -45,7 +45,7 @@ L =item 9 -L +L =back @@ -107,15 +107,17 @@ B: Note that all of the code for this part of the tutorial can be pulled from the Catalyst Subversion repository in one step with the following command: - svn checkout http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial@4609 . - IMPORTANT: Does not work yet. Will be completed for final version. + svn co http://dev.catalyst.perl.org/repos/Catalyst/tags/examples/Tutorial/MyApp/5.7/CatalystBasics MyApp =head1 CREATE A CATALYST PROJECT Catalyst provides a number of helper scripts that can be used to quickly flesh out the basic structure of your application. All Catalyst projects -begin with the C helper. +begin with the C helper (see L +for more information on helpers). Also note that as of Catalyst 5.7000, +you will not have the helper scripts unless you install both +L and L. In the case of this tutorial, use the Catalyst C script to initialize the framework for an application called C: @@ -162,7 +164,7 @@ application with the built-in development web server: | /end | MyApp::Controller::Root | end | '----------------------+--------------------------------------+--------------' - [info] MyApp powered by Catalyst 5.70 + [info] MyApp powered by Catalyst 5.7000 You can connect to your server at http://localhost.localdomain:3000 Point your web browser to L (substituting a @@ -171,14 +173,14 @@ greeted by the Catalyst welcome screen. Information similar to the following should be appended to the logging output of the development server: - [info] *** Request 1 (0.008/s) [2822] [Mon Jul 3 12:42:43 2006] *** + [info] *** Request 1 (0.043/s) [6003] [Fri Jul 7 13:32:53 2006] *** [debug] "GET" request for "/" from "127.0.0.1" - [info] Request took 0.154781s (6.461/s) + [info] Request took 0.067675s (14.777/s) .----------------------------------------------------------------+-----------. | Action | Time | +----------------------------------------------------------------+-----------+ - | /default | 0.069475s | - | /end | 0.085305s | + | /default | 0.002844s | + | /end | 0.000207s | '----------------------------------------------------------------+-----------' Press Ctrl-C to break out of the development server. @@ -369,13 +371,13 @@ on one (or more) lines as with the default configuration. B You may see examples that include the L -plugins. As of Catalyst 5.70, C has been +plugins. As of Catalyst 5.7000, C has been deprecated in favor of L (as the name of the package suggests, C is not a plugin, but an action). The purpose of both is essentially the same: forward processing to the view to be rendered. Applications generated -under 5.70 should automatically use C and "just work" +under 5.7000 should automatically use C and "just work" for most applications. For more information on C and the various options for forwarding to your view logic, please refer to the "Using RenderView for the Default View" section under @@ -694,7 +696,8 @@ to the controller: $c->stash->{books} = [$c->model('MyAppDB::Book')->all]; # Set the TT template to use. You will almost always want to do this - # in your action methods. + # in your action methods (actions methods respond to user input in + # your controllers). $c->stash->{template} = 'books/list.tt2'; } @@ -789,7 +792,7 @@ Catalyst C variable.) B: When troubleshooting TT it can be helpful to enable variable C options. You can do this in a Catalyst environment by adding a C line to the C<__PACKAGE__->config> declaration in -C: +C: __PACKAGE__->config({ CATALYST_VAR => 'Catalyst', @@ -809,7 +812,7 @@ for use inside Catalyst). Once your controller logic has processed the request from a user, it forwards processing to your view in order to generate the appropriate -response output. Catalyst v5.70 ships with a new mechanism, +response output. Catalyst v5.7000 ships with a new mechanism, L, that automatically performs this operation. If you look in C, you should see the this empty @@ -873,9 +876,10 @@ Older Catalyst-related documents often suggest that you add a "private end action" to your application class (C) or Root.pm (C). These examples should be easily converted to L by simply adding -C to the C definition. If end sub is -defined in your application class (C), you should also migrate -it to C. +the attribute C<:ActionClass('RenderView')> to the C +definition. If end sub is defined in your application class +(C), you should also migrate it to +C. =item * @@ -887,7 +891,8 @@ that C be added to the list of plugins in C. It also allowed you to add "dump_info=1" (precede with "?" or "&" depending on where it is in the URL) to I the debug screen at the end of the Catalyst request processing cycle. However, it was more -difficult to extend the C mechanism, and is now deprecated. +difficult to extend than the C mechanism, and is now +deprecated. =item * @@ -971,13 +976,16 @@ Then open C in your editor and enter: [% # First initialize a TT variable to hold a list. Then use a TT FOREACH -%] [% # loop in 'side effect notation' to load just the last names of the -%] - [% # authors into the list. Note that we make a bogus assignment to the -%] - [% # 'unused' vbl to avoid printing the size of the list after each push. -%] + [% # authors into the list. Note that the 'push' TT vmethod does not -%] + [% # a value, so nothing will be printed here. But, if you have something -%] + [% # in TT that does return a method and you don't want it printed, you -%] + [% # can: 1) assign it to a bogus value, or 2) use the CALL keyword to -%] + [% # call it and discard the return value. -%] [% tt_authors = [ ]; - unused = tt_authors.push(author.last_name) FOREACH author = book.authors %] + tt_authors.push(author.last_name) FOREACH author = book.authors %] [% # Now use a TT 'virtual method' to display the author count in parens -%] ([% tt_authors.size %]) - [% # Use another vmethod to join & print the names with comma separators -%] + [% # Use another TT vmethod to join & print the names & comma separators -%] [% tt_authors.join(', ') %] @@ -1077,7 +1085,7 @@ Your development server log output should display something like: | /books/list | /books/list | '-------------------------------------+--------------------------------------' - [info] MyApp powered by Catalyst 5.70 + [info] MyApp powered by Catalyst 5.7000 You can connect to your server at http://localhost.localdomain:3000 Some things you should note in the output above: @@ -1130,7 +1138,7 @@ information for each book. Kennedy Clark, C Please report any errors, issues or suggestions to the author. The -most recent version of the Catlayst Tutorial can be found at +most recent version of the Catalyst Tutorial can be found at L. Copyright 2006, Kennedy Clark, under Creative Commons License