X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FMoreCatalystBasics.pod;h=2c22731caf92b43f0fec92ad6d741f201bc90f77;hp=8848afaf3cb79dc7dc085f5f9c0a99719e229d1b;hb=b411df01b40662f125aa854a7c25097bc53ad86a;hpb=19c490898919f6b904d6e7e05cb671984cb2cad7 diff --git a/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod b/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod index 8848afa..2c22731 100644 --- a/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod +++ b/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod @@ -87,7 +87,7 @@ tutorial): $ cd MyApp This creates a similar skeletal structure to what we saw in Part 2 of -the tutorial, except with C or C substituted for +the tutorial, except with C and C substituted for C and C. @@ -140,29 +140,33 @@ very similar to Apache configuration files. We will see how to use this feature of Catalyst during the authentication and authorization sections (Part 5 and Part 6). -B: If you are following along in Ubuntu 8.04 or -otherwise using a version of Catalyst prior to v5.7014, you need to be -aware that Catalyst changed from a default format of YAML to the more -straightforward C format. Because Catalyst has long -supported both formats, this tutorial will simply use a configuration -file called C instead of C and Catatlyst will -automcatically use the new format. Just be aware that earlier versions -of Catalyst will still create the C file and that you will -need to B> and create a new C file by -hand, but otherwise this transition is very painless. The default -contents of C should only consist of one line: C. Also be aware that you can continue to use any format -supported by -L and -L, including YAML -- Catalyst will -automatically look for any of the supported configuration file formats. - -C: This script can be useful for converting between configuration +B If you are following along in Ubuntu 8.04 or +otherwise using a version of L prior +to version 1.06, you need to be aware that Catalyst changed from a +default format of YAML to the more straightforward C +format. Because Catalyst has long supported both formats, this +tutorial will simply use a configuration file called C +instead of C and Catatlyst will automcatically use the new +format. Just be aware that earlier versions of Catalyst will still +create the C file and that you will need to B> and create a new C file by hand, but +otherwise this transition is very painless. The default contents of +C should only consist of one line: C. Also be +aware that you can continue to use any format supported by +L and +L, including YAML -- Catalyst will +automatically look for any of the supported configuration file +formats. + +B: This script can be useful for converting between configuration formats: perl -Ilib -e 'use MyApp; use Config::General; Config::General->new->save_file("myapp.conf", MyApp->config);' +B The default C should look like: + + name MyApp =item * @@ -182,12 +186,12 @@ with: Replace it with: use Catalyst qw/ - -Debug - ConfigLoader - Static::Simple - - StackTrace - /; + -Debug + ConfigLoader + Static::Simple + + StackTrace + /; This tells Catalyst to start using one new plugin: @@ -204,6 +208,10 @@ Note: L output appears in your browser, not in the console window from which you're running your application, which is where logging output usually goes. +B You will want to disable +L before you put your +application into production, but it can be helpful during development. + =back Note that when specifying plugins on the C line, you can @@ -244,7 +252,7 @@ to the controller: # Retrieve all of the book records as book model objects and store in the # stash where they can be accessed by the TT template - $c->stash->{books} = [$c->model('MyAppDB::Books')->all]; + $c->stash->{books} = [$c->model('DB::Books')->all]; # Set the TT template to use. You will almost always want to do this # in your action methods (action methods respond to user input in @@ -253,7 +261,7 @@ to the controller: } B This won't actually work yet since you haven't set up your -model yet. +model yet. We will be covering the model soon. B Programmers experienced with object-oriented Perl should recognize C<$self> as a reference to the object where this method was @@ -263,20 +271,20 @@ C<$context>). The Context object is automatically passed to all Catalyst components. It is used to pass information between components and provide access to Catalyst and plugin functionality. -B: You may see the C<$c-Emodel('MyAppDB::Book')> used above -written as C<$c-Emodel('MyAppDB')-Eresultset('Book)>. The two +B: You may see the C<$c-Emodel('DB::Book')> used above +written as C<$c-Emodel('DB')-Eresultset('Book')>. The two are equivalent. B Catalyst actions are regular Perl methods, but they make use of Nicholas Clark's C module (that's the C<: Local> next to the C in the code above) to provide additional information to the Catalyst dispatcher logic. Many newer Catalyst -applications are switching to the use of "Literal" C<: Path> actions +applications are switching to the use of "Literal" C<:Path> actions and C attribute in lieu of C<: Local> and C<: Private>. For -example, C can be used instead of +example, C can be used instead of C (because no path was supplied to C it matches the "empty" URL in the namespace of that module... the same -thing C would do) or C +thing C would do) or C could be used instead of the C above (the C argument to C would make it match on the URL C under C, the namespace of the current module). See "Action Types" in @@ -297,11 +305,11 @@ possibly using other display output- generation systems. As with virtually every aspect of Catalyst, options abound when it comes to the specific view technology you adopt inside your application. However, most Catalyst applications use the Template Toolkit, known as -TT (for more information on TT, see L). Other popular view technologies include Mason -(L and L) and -L (L). +TT (for more information on TT, see +L). Other popular view technologies +include Mason (L and +L) and L +(L). =head2 Create a Catalyst View Using C @@ -353,30 +361,12 @@ directories that can be used to customize the look and feel of your application. Also take a look at C for config values set by the C helper. -B: Note that TTSite does one thing that could confuse people who -are used to the normal C Catalyst view: it redefines the Catalyst -context object in templates from its usual C to C. When -looking at other Catalyst examples, remember that they almost always use -C. Note that Catalyst and TT I when you use the -wrong name to access the context object...TT simply outputs blanks for -that bogus logic (see next tip to change this behavior with TT C -options). Finally, be aware that this change in name I -applies to how the context object is accessed inside your TT templates; -your controllers will continue to use C<$c> (or whatever name you use -when fetching the reference from C<@_> inside your methods). (You can -change back to the "default" behavior be removing the C -line from C, but you will also have to edit -C and C. If you do this, be -careful not to have a collision between your own C variable and the -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: __PACKAGE__->config({ - CATALYST_VAR => 'Catalyst', ... DEBUG => 'undef', ... @@ -387,7 +377,7 @@ of the package where it is used. Therefore, in C, C<__PACKAGE__> is equivalent to C. There are a variety of options you can use, such as 'undef', 'all', -'service', 'context', 'parser', 'provider', and 'service'. See +'service', 'context', 'parser' and 'provider'. See L for more information (remove the C portion of the name shown in the TT docs and convert to lower case for use inside Catalyst). @@ -479,7 +469,7 @@ for details and examples). In addition to the usual C