[Catalyst-commits] r11678 - Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial

hkclark at dev.catalyst.perl.org hkclark at dev.catalyst.perl.org
Wed Oct 28 02:06:19 GMT 2009


Author: hkclark
Date: 2009-10-28 02:06:19 +0000 (Wed, 28 Oct 2009)
New Revision: 11678

Modified:
   Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/01_Intro.pod
   Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/02_CatalystBasics.pod
   Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/03_MoreCatalystBasics.pod
   Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod
   Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/05_Authentication.pod
   Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/06_Authorization.pod
Log:
Update tutorial for latest versions of Cat-related modules for Debian.
Misc cleanup/freshing up of tutorial.
A few bug fixes from RT.
Still need to wrap up Ch 7 - 10 before pushing to cpan.

Modified: Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/01_Intro.pod
===================================================================
--- Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/01_Intro.pod	2009-10-28 00:34:02 UTC (rev 11677)
+++ Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/01_Intro.pod	2009-10-28 02:06:19 UTC (rev 11678)
@@ -92,12 +92,14 @@
 for some of the key modules), so B<if you think you might be running 
 into an issue related to versions> (for example, a module changed its 
 behavior in a newer version or a bug was introduced), B<it might be 
-worth giving Debian 5 a try>.  See the "CATALYST INSTALLATION" 
-section below for more information.
+worth giving Debian 5 a try>.
 
-If you're reading this manual online, you can download the example 
+If you plan to follow along with Debian 5, you can jump down to the 
+"Debian" section under L</"CATALYST INSTALLATION"> below and it will walk you 
+though the setup of a fully functional Catalyst environment. If you 
+would prefer to install directly from CPAN, you can download the example 
 program and all the necessary dependencies to your local machine by 
-installing the C<Task::Catalyst::Tutorial> distribution from CPAN:
+installing the C<Task::Catalyst::Tutorial> distribution: 
 
      cpan Task::Catalyst::Tutorial
 
@@ -153,7 +155,10 @@
 =item * 
 
 The use of SQLite as a database (with code also provided for MySQL and
-PostgreSQL).
+PostgreSQL).  (Note: Because we make use of the DBIx::Class Object 
+Relational Mapping [ORM] layer, out our application will be database
+agnostic and can easily be used by any of the databases supported
+by DBIx::Class.)
 
 =item * 
 
@@ -194,15 +199,15 @@
 
 =item * 
 
-Catalyst v5.80004
+Catalyst v5.80013
 
 =item *
 
-Catalyst::Devel v1.10
+Catalyst::Devel v1.15
 
 =item * 
 
-DBIx::Class v0.08102
+DBIx::Class v0.08108
 
 =item *
 
@@ -229,23 +234,23 @@
 
 =item *
 
-Catalyst::Plugin::ConfigLoader -- v0.22
+Catalyst::Plugin::ConfigLoader -- v0.23
 
 =item *
 
-Catalyst::Plugin::Session -- v0.20
+Catalyst::Plugin::Session -- v0.22
 
 =item *
 
-Catalyst::Plugin::Session::State::Cookie -- v0.10
+Catalyst::Plugin::Session::State::Cookie -- v0.11
 
 =item *
 
-Catalyst::Plugin::Session::Store::FastMmap -- v0.07
+Catalyst::Plugin::Session::Store::FastMmap -- v0.10
 
 =item *
 
-Catalyst::Plugin::StackTrace -- v0.09
+Catalyst::Plugin::StackTrace -- v0.10
 
 =item *
 
@@ -261,22 +266,28 @@
     perl -M<_mod_name_> -e '"print $<_mod_name_>::VERSION\n"'
 
 For example:
-    perl -MCatalyst::Plugin::StackTrace -e 'print "$Catalyst::Plugin::StackTrace::VERSION\n"'
 
-Since the web browser is being used on the same box where Perl and the
-Catalyst development server is running, the URL of
-C<http://localhost:3000> will be used (the Catalyst development server
-defaults to port 3000).  If you are running Perl on a different box than
-where your web browser is located (or using a different port number via
-the C<-p> I<port_number> option to the development server), then you
-will need to update the URL you use accordingly.
+    perl -MCatalyst -e 'print "$Catalyst::VERSION\n";'
 
+or:
+
+    perl -MCatalyst::Devel -e 'print "$Catalyst::Devel::VERSION\n";'
+
 =item * 
 
-Depending on the web browser you are using, you might need to hit 
-C<Shift+Reload> or C<Ctrl+Reload> to pull a fresh page when testing 
-your application at various points (see 
-L<http://en.wikipedia.org/wiki/Bypass_your_cache> for a comprehensive
+This tutorial will assume that the web browser is located on the same 
+system where the Catalyst development server is running, and 
+therefore use a URL of C<http://localhost:3000> (the Catalyst 
+development server defaults to port 3000).  If you are running Perl on 
+a different box than where your web browser is located (or using a 
+different port number via the C<-p> I<port_number> option to the 
+development server), then you will need to update the URL you use 
+accordingly.
+
+Please Note: Depending on the web browser you are using, you might 
+need to hit C<Shift+Reload> or C<Ctrl+Reload> to pull a fresh page 
+when testing your application at various points (see 
+L<http://en.wikipedia.org/wiki/Bypass_your_cache> for a comprehensive 
 list of options for each browser).  Also, the C<-k> keepalive option 
 to the development server can be necessary with some browsers 
 (especially Internet Explorer).
@@ -389,14 +400,13 @@
 
     sudo aptitude update
     sudo aptitude -y install sqlite3 libdbd-sqlite3-perl libcatalyst-perl \
-        libcatalyst-modules-perl libconfig-general-perl libsql-translator-perl \
-        libdatetime-perl libdatetime-format-mysql-perl libio-all-perl \
-        libperl6-junction-perl libmoosex-emulate-class-accessor-fast-perl \
-        libdbix-class-timestamp-perl
+        libcatalyst-modules-perl libdbix-class-timestamp-perl \
+        libdbix-class-encodedcolumn-perl libperl6-junction-perl \
+        libdatetime-format-sqlite-perl
 
-Let it install (normally about a 30-second operaton) and you are done. 
-(Note the '\' above.  Depending on your environment, you might be able 
-to cut and paste the text as shown or need to remove the '\' 
+Let it install (normally about a 30 to 90-second operaton) and you are 
+done. (Note the '\' above.  Depending on your environment, you might 
+be able to cut and paste the text as shown or need to remove the '\' 
 characters to that the command is all on a single line.)
 
 If you are using an image other than the "rescue" ISO, you will also need
@@ -432,7 +442,9 @@
 =item *
 
 If you are installing modules from CPAN, you can free up some space 
-with "C<rm -rf /root/.cpan/*>".
+with "C<rm -rf /root/.cpan/*>" (change "/root/" in the previous 
+command to match your home directory or the location where CPAN
+has been configured to perform build operations).
 
 =item *
 
@@ -604,8 +616,6 @@
 B<NOTE:> You can run the test cases for the final code through Chapter 8 
 with the following commands:
 
-    sudo cpan Catalyst::Model::DBIC::Schema Time::Warp DBICx::TestDatabase \
-        DBIx::Class::DynamicDefault DBIx::Class::EncodedColumn
     wget http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/MyApp_Chapter8.tgz
     tar zxvf MyApp_Chapter8.tgz
     cd MyApp
@@ -613,13 +623,12 @@
 
 If you wish to include the L<HTML::FormFu|HTML::FormFu> section in 
 your tests, substitute C<MyApp_Chapter9_FormFu.tgz> for 
-C<MyApp_Chapter8.tgz> in the URL above.  However, you will also need to 
-run the following additional commands:
+C<MyApp_Chapter8.tgz> in the URL above.
 
-    sudo aptitude -y install libhtml-formfu-perl libmoose-perl \
-        libregexp-assemble-perl libhtml-formfu-model-dbic-perl
-    sudo aptitude clean
-    sudo cpan Catalyst::Component::InstancePerContext Catalyst::Controller::HTML::FormFu
+    wget http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/MyApp_Chapter9_FormFu.tgz
+    tar zxvf MyApp_Chapter8.tgz
+    cd MyApp
+    CATALYST_DEBUG=0 prove --lib lib t
 
 You can also fire up the application under the development server that is conveniently
 built in to Catalyst.  Just issue this command from the C<MyApp> directory where you

Modified: Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/02_CatalystBasics.pod
===================================================================
--- Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/02_CatalystBasics.pod	2009-10-28 00:34:02 UTC (rev 11677)
+++ Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/02_CatalystBasics.pod	2009-10-28 02:06:19 UTC (rev 11678)
@@ -103,7 +103,8 @@
 
 The use of Object-Relational Mapping (ORM) technology for database
 access. Specifically, ORM provides an automated and standardized means
-to persist and restore objects to/from a relational database.
+to persist and restore objects to/from a relational database and will
+automatically create our Catalyst model for use with a database.
 
 =back
 
@@ -132,8 +133,13 @@
     created "Hello/root"
     ...
     created "Hello/script/hello_create.pl"
+    Change to application directory and Run "perl Makefile.PL" to make sure your install is complete
     $ cd Hello
 
+Note: If you are using Strawberry Perl on Win32, drop the ".pl"
+from the end of the "catalyst.pl" command and simply use
+"catalyst Hello".
+
 The C<catalyst.pl> helper script will display the names of the
 directories and files it creates:
 
@@ -187,8 +193,8 @@
     [debug] Statistics enabled
     [debug] Loaded plugins:
     .----------------------------------------------------------------------------.
-    | Catalyst::Plugin::ConfigLoader  0.20                                       |
-    | Catalyst::Plugin::Static::Simple  0.20                                     |
+    | Catalyst::Plugin::ConfigLoader  0.23                                       |
+    | Catalyst::Plugin::Static::Simple  0.21                                     |
     '----------------------------------------------------------------------------'
     
     [debug] Loaded dispatcher "Catalyst::Dispatcher"
@@ -219,7 +225,7 @@
     | /                                   | /index                               |
     '-------------------------------------+--------------------------------------'
     
-    [info] Hello powered by Catalyst 5.80004
+    [info] Hello powered by Catalyst 5.80013
     You can connect to your server at http://debian:3000
 
 Point your web browser to L<http://localhost:3000> (substituting a 
@@ -229,8 +235,8 @@
 in your URL).  Information similar to the following should be appended 
 to the logging output of the development server:
 
-    [info] *** Request 1 (0.005/s) [20712] [Sun Mar  8 15:49:09 2009] ***
-    [debug] "GET" request for "/" from "1.1.1.98"
+    [info] *** Request 1 (0.005/s) [20712] [Sun Oct 11 11:58:51 2009] ***
+    [debug] "GET" request for "/" from "172.0.0.1"
     [info] Request took 0.007342s (136.203/s)
     .----------------------------------------------------------------+-----------.
     | Action                                                         | Time      |
@@ -273,28 +279,27 @@
 is a special method that returns the welcome message that you saw in 
 your browser.
 
-The ":Path :Args(0)" after the method name are attributes which determine 
-which URLs will be dispatched to this method. (Depending on your version of 
-Catalyst, it used to say "Private" but using that with 'default' or 'index' 
-is currently deprecated.)
+The ":Path :Args(0)" after the method name are attributes which 
+determine which URLs will be dispatched to this method. (You might see 
+":Private" if you are using an older version of Catalyst, but using 
+that with 'default' or 'index' is currently deprecated.  If so, you 
+should also probably upgrade before continuing the tutorial.)
 
 Some MVC frameworks handle dispatching in a central place. Catalyst, 
 by policy, prefers to handle URL dispatching with attributes on 
 controller methods. There is a lot of flexibility in specifying which 
 URLs to match.  This particular method will match all URLs, because it 
 doesn't specify the path (nothing comes after "Path"), but will only 
-accept a single args because of the ":Args(0)". 
+accept a URL without any args because of the ":Args(0)". 
 
-The default is to map URLs to controller names, and because of 
-the way that Perl handles namespaces through package names, 
-it is simple to create hierarchical structures in 
-Catalyst. This means that you can create controllers with deeply 
-nested actions in a clean and logical way. 
+The default is to map URLs to controller names, and because of the way 
+that Perl handles namespaces through package names, it is simple to 
+create hierarchical structures in Catalyst. This means that you can 
+create controllers with deeply nested actions in a clean and logical 
+way. For example, the URL C<http://hello.com/admin/articles/create> 
+maps to the package C<Hello::Controller::Admin::Articles>, and the 
+C<create> method. 
 
-For example, the URL C<http://hello.com/admin/articles/create> maps 
-to the package C<Hello::Controller::Admin::Articles>, and the C<create>
-method. 
-
 Add the following subroutine to your C<lib/Hello/Controller/Root.pm> 
 file:
 
@@ -310,17 +315,18 @@
 Here you're sending your own string to the webpage.
 
 Save the file, start the server (stop and restart it if it's still 
-up), and go to L<http://localhost:3000/hello> to 
-see "Hello, World!"
+running), and go to L<http://localhost:3000/hello> to 
+see "Hello, World!"  Also notice that a new action is listed under
+"Loaded Private actions" in the development server debug output.
 
 
 =head2 Hello, World! Using a View and a Template
 
-In the Catalyst world  a "View" is not a page of XHTML or a template 
-designed to present a page to a browser. It is the module that 
-determines the I<type> of view -- HTML, pdf, XML, etc. For the 
-thing that generates the I<content> of that view, (such as the 
-default Toolkit Template) the actual templates go under the 
+In the Catalyst world a "View" itself is not a page of XHTML or a 
+template designed to present a page to a browser. Rather, it is the 
+module that determines the I<type> of view -- HTML, pdf, XML, etc. For 
+the thing that generates the I<content> of that view (such as the a 
+Toolkit Template template file), the actual templates go under the 
 "root" directory.
 
 To create a TT view, run:
@@ -344,15 +350,16 @@
 
 =item *
 
-The final "TT" tells it that you are creating a Template Toolkit view.
+The final "TT" tells Catalyst the I<type> of the view, with "TT" 
+indicating that you want to a Template Toolkit view.
 
 =back
 
-If you look at C<lib/Hello/View/TT.pm> you will find that it only contains a
-config statement to set the TT extension to ".tt".
+If you look at C<lib/Hello/View/TT.pm> you will find that it only 
+contains a config statement to set the TT extension to ".tt".
 
 Now that the TT.pm "View" exists, Catalyst will autodiscover it and be 
-able to use it to display the view templates, using the "process" 
+able to use it to display the view templates using the "process" 
 method that it inherits from the C<Catalyst::View::TT class>.
 
 Template Toolkit is a very full featured template facility, with 
@@ -383,14 +390,15 @@
         $c->stash->{template} = 'hello.tt';
     }
 
-This time, instead of doing C<$c-E<gt>response-E<gt>body()>, you are setting 
-the value of the "template" hash key in the Catalyst "stash", an area 
-for putting information to share with other parts of your application. 
-The "template" key determines which template will be displayed at the 
-end of the method. Catalyst controllers have a default "end" action 
-for all methods which causes the first (or default) view to be 
-rendered (unless there's a C<$c-E<gt>response-E<gt>body()> statement). So your 
-template will be magically displayed at the end of your method.
+This time, instead of doing C<$c-E<gt>response-E<gt>body()>, you are 
+setting the value of the "template" hash key in the Catalyst "stash", 
+an area for putting information to share with other parts of your 
+application. The "template" key determines which template will be 
+displayed at the end of the request cycle. Catalyst controllers have a 
+default "end" action for all methods which causes the first (or 
+default) view to be rendered (unless there's a C<$c-E<gt>response-
+E<gt>body()> statement). So your template will be magically displayed 
+at the end of your method.
 
 After saving the file, restart the development server, and look at 
 L<http://localhost:3000/hello> again. You should 
@@ -405,8 +413,7 @@
 
 This will create a C<lib/Hello/Controller/Site.pm> file (and a test 
 file). Bring Site.pm up in your editor, and you can see that there's 
-not much there. Most people probably don't bother to use the create 
-script to make controllers after they're used to using Catalyst.
+not much there. 
 
 In C<lib/Hello/Controller/Site.pm>, add the following method:
 
@@ -418,8 +425,8 @@
     }
 
 Notice the "Local" attribute on the C<test> method. This will cause 
-the C<test> action (now that we have assigned an action type to the 
-method it appears as a controller "action" to Catalyst) to be executed 
+the C<test> action (now that we have assigned an "action type" to the 
+method it appears as a "controller action" to Catalyst) to be executed 
 on the "controller/method" URL, or, in this case, "site/test".  We 
 will see additional information on controller actions throughout the 
 rest of the tutorial, but if you are curious take a look at 

Modified: Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/03_MoreCatalystBasics.pod
===================================================================
--- Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/03_MoreCatalystBasics.pod	2009-10-28 00:34:02 UTC (rev 11677)
+++ Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/03_MoreCatalystBasics.pod	2009-10-28 02:06:19 UTC (rev 11678)
@@ -91,11 +91,13 @@
     created "MyApp/root"
     ...
     created "MyApp/script/myapp_create.pl"
+    Change to application directory and Run "perl Makefile.PL" to make sure your install is complete
     $ cd MyApp
 
 This creates a similar skeletal structure to what we saw in Chapter 2 of
 the tutorial, except with C<MyApp> and C<myapp> substituted for
-C<Hello> and C<hello>.
+C<Hello> and C<hello>.  (As noted in Chapter 2, omit the ".pl" from 
+the command if you are using Strawberry Perl.)
 
 
 =head1 EDIT THE LIST OF CATALYST PLUGINS
@@ -119,16 +121,32 @@
 C<script/myapp_server.pl> development server earlier.  You can remove
 this item when you place your application into production.
 
-As you may have noticed, C<-Debug> is not a plugin, but a I<flag>. 
+To be technically correct, it turns out that C<-Debug> is not a plugin, but a I<flag>. 
 Although most of the items specified on the C<__PACKAGE__-E<gt>setup> 
 line of your application class will be plugins, Catalyst supports a 
 limited number of flag options (of these, C<-Debug> is the most 
 common).  See the documentation for C<Catalyst.pm> to get details on 
 other flags (currently C<-Engine>, C<-Home>, and C<-Log>).
 
-If you prefer, you can use the C<$c-E<gt>debug> method to enable debug
-messages.
+If you prefer, there are several other ways to enable debug output:
 
+=over 4
+
+=item *
+
+Use the C<$c-E<gt>debug> method
+
+=item *
+
+The C<-d> option to C<script/myapp_server.pl>
+
+=item *
+
+The C<CATALYST_DEBUG=1> environment variable (or set it to
+zero to templorarily disable debug output).
+
+=back
+
 B<TIP>: Depending on your needs, it can be helpful to permanently
 remove C<-Debug> from C<lib/MyApp.pm> and then use the C<-d> option
 to C<script/myapp_server.pl> to re-enable it just for the development
@@ -214,8 +232,8 @@
 browser, not in the console window from which you're running your 
 application, which is where logging output usually goes.
 
-Make sure that when adding new plugins that you include them as a new
-dependancies within the Makefile.PL file. For example, after adding
+Make sure when adding new plugins you also include them as a new
+dependancy within the Makefile.PL file. For example, after adding
 the StackTrace plugin the Makefile.PL should include the following
 line:
 
@@ -240,10 +258,9 @@
 
 =item *
 
-When specifying plugins on the C<__PACKAGE__-E<gt>setup> line, you can 
-omit C<Catalyst::Plugin::> from the name.  Additionally, you can 
-spread the plugin names across multiple lines as shown here, or place 
-them all on one (or more) lines as with the default configuration.
+When specifying plugins, you can omit C<Catalyst::Plugin::> from the 
+name.  Additionally, you can spread the plugin names across multiple 
+lines as shown here or place them all on one line.
 
 =back
 
@@ -315,7 +332,7 @@
 =item *
 
 B<:Private> -- Use C<:Private> for methods that you want to make into 
-an action, but you do not want Catalyst to directly expose  
+an action, but you do not want Catalyst to directly expose  the method 
 to your users.  Catalyst will not map C<:Private> methods to a URI. 
 Use them for various sorts of "special" methods (the C<begin>, 
 C<auto>, etc. discussed below) or for methods you want to be able to 
@@ -351,11 +368,11 @@
 B<:Path> -- C<:Path> actions let you map a method to an explicit URI 
 path.  For example, "C<:Path('list')>" in 
 C<lib/MyApp/Controller/Books.pm> would match on the URL 
-C<http://localhost:3000/books/list> but "C<:Path('/list')>" would match 
-on C<http://localhost:3000/list>.  You can use C<:Args()> to specify 
-how many arguments an action should accept.  See 
-L<Catalyst::Manual::Intro/Action_types> for more information and a few 
-examples.
+C<http://localhost:3000/books/list>, but "C<:Path('/list')>" would 
+match on C<http://localhost:3000/list> (because of the leading slash). 
+You can use C<:Args()> to specify how many arguments an action should 
+accept.  See L<Catalyst::Manual::Intro/Action_types> for more 
+information and examples.
 
 =item *
 
@@ -406,35 +423,12 @@
 
 =head2 Create a Catalyst View
 
-When using TT for the Catalyst view, there are two main helper scripts:
+When using TT for the Catalyst view, the main helper script
+is L<Catalyst::Helper::View::TT|Catalyst::Helper::View::TT>.
+You may also come across references to 
+L<Catalyst::Helper::View::TTSite|Catalyst::Helper::View::TTSite>,
+but its use is now deprecated.
 
-=over 4
-
-=item *
-
-L<Catalyst::Helper::View::TT|Catalyst::Helper::View::TT>
-
-=item *
-
-L<Catalyst::Helper::View::TTSite|Catalyst::Helper::View::TTSite>
-
-=back
-
-Both helpers are similar. C<TT> creates the C<lib/MyApp/View/TT.pm>
-file and leaves the creation of any hierarchical template organization
-entirely up to you. (It also creates a C<t/view_TT.t> file for testing;
-test cases will be discussed in Chapter 8.) C<TTSite>, on the other hand, 
-creates a modular and hierarchical view layout with
-separate Template Toolkit (TT) files for common header and footer
-information, configuration values, a CSS stylesheet, and more.
-
-While C<TTSite> was useful to bootstrap a project, its use is now
-deprecated and it should be considered historical.  For most Catalyst
-applications it adds redundant functionality and structure; many in the
-Catalyst community recommend that it's easier to learn both Catalyst and
-Template Toolkit if you use the more basic C<TT> approach.
-Consequently, this tutorial will use "plain old TT."
-
 Enter the following command to enable the C<TT> style of view
 rendering for this tutorial:
 
@@ -472,14 +466,15 @@
 B<NOTE:> Make sure to add a comma after '.tt2' outside the single
 quote.
 
-This changes the default extension for Template Toolkit from '.tt' to
-'.tt2' and changes the base directory for your template files from
-C<root> to C<root/src>.  These changes from the default are done mostly
-to facilitate the application we're developing in this tutorial; as with
-most things Perl, there's more than one way to do it...
+This changes the default extension for Template Toolkit from '.tt' to 
+'.tt2' and changes the base directory for your template files from 
+C<root> to C<root/src>.  Stick with these conventions for the 
+tutorial, but feel free to use whatever options you desire in your 
+applications (as with most things Perl, there's more than one way to 
+do it...).
 
 B<Note:> We will use C<root/src> as the base directory for our 
-template files, which a full naming convention of 
+template files, with a full naming convention of 
 C<root/src/_controller_name_/_action_name_.tt2>.  Another popular option is to
 use C<root/> as the base (with a full filename pattern of 
 C<root/_controller_name_/_action_name_.tt2>).
@@ -521,21 +516,25 @@
 The C<[%> and C<%]> tags are used to delimit Template Toolkit code.  TT
 supports a wide variety of directives for "calling" other files,
 looping, conditional logic, etc.  In general, TT simplifies the usual
-range of Perl operators down to the single dot (C<.>) operator.  This
+range of Perl operators down to the single dot (".") operator.  This
 applies to operations as diverse as method calls, hash lookups, and list
 index values (see
 L<http://search.cpan.org/perldoc?Template::Manual::Variables> for
-details and examples).  In addition to the usual C<Template> module Pod
+details and examples).  In addition to the usual L<Template> module Pod
 documentation, you can access the TT manual at
 L<http://search.cpan.org/perldoc?Template::Manual>.
 
-B<TIP:> While you can build all sorts of complex logic into your TT
-templates, you should in general keep the "code" part of your templates
-as simple as possible.  If you need more complex logic, create helper
-methods in your model that abstract out a set of code into a single call
-from your TT template.  (Note that the same is true of your controller
-logic as well -- complex sections of code in your controllers should
-often be pulled out and placed into your model objects.)
+B<TIP:> While you can build all sorts of complex logic into your TT 
+templates, you should in general keep the "code" part of your 
+templates as simple as possible.  If you need more complex logic, 
+create helper methods in your model that abstract out a set of code 
+into a single call from your TT template.  (Note that the same is true 
+of your controller logic as well -- complex sections of code in your 
+controllers should often be pulled out and placed into your model 
+objects.)  In Chapter 4 of the tutorial we will explore some extremely 
+helpful and powerful features of L<DBIx::Class> that allow you to pull 
+code out of your views and controllers and place it where it 
+rightfully belongs in a model class.
 
 
 =head2 Test Run The Application
@@ -665,7 +664,7 @@
 
 Catalyst can be used with virtually any form of datastore available 
 via Perl.  For example, L<Catalyst::Model::DBI|Catalyst::Model::DBI> 
-can be used to access databases through the traditional Perl C<DBI> 
+can be used to access databases through the traditional Perl L<DBI> 
 interface or you can use a model to access files of any type on the 
 filesystem.  However, most Catalyst applications use some form of 
 object-relational mapping (ORM) technology to create objects 
@@ -697,8 +696,9 @@
 be able to cut and paste the text as shown or need to remove the '\' 
 character to that the command is all on a single line.
 
-If you don't have version 0.23 or higher, please run this command
-to install it directly from CPAN:
+You should have version 0.23 or greater if you are following along 
+with Debian 5.  In other environments, you may need to run this 
+command to install it directly from CPAN:
 
     $ sudo cpan Catalyst::Model::DBIC::Schema
 
@@ -1010,10 +1010,10 @@
 =head2 Configure TT.pm For The Wrapper
 
 In order to create a wrapper, you must first edit your TT view and
-tell it where to find your wrapper file. Your TT view is located in
-C<lib/MyApp/View/TT.pm>.
+tell it where to find your wrapper file. 
 
-Edit C<lib/MyApp/View/TT.pm> and change it to match the following:
+Edit you TT view in C<lib/MyApp/View/TT.pm> and change it to match the 
+following:
 
     __PACKAGE__->config(
         # Change default TT extension
@@ -1276,9 +1276,8 @@
 Result Classes we created).
 
 Then hit the URL L<http://localhost:3000/books/list> with your browser 
-and be sure that the book list is displayed via the relationships 
-established above. You can leave the development server running for 
-the next step if you wish.
+and be sure that the book list still displays correctly. You can leave 
+the development server running for the next step if you wish.
 
 B<Note:> You will not see the authors yet because the view does not yet 
 use the new relations. Read on to the next section where we update the 
@@ -1312,13 +1311,13 @@
     </td>
     ...
 
-B<IMPORTANT NOTE:> You should keep as much "logic code" as possible 
-out of your views.  Instead, this kind of logic belongs in your model 
+B<IMPORTANT NOTE:> Again, you should keep as much "logic code" as 
+possible out of your views.  This kind of logic belongs in your model 
 (the same goes for controllers -- keep them as "thin" as possible and 
 push all of the "complicated code" out to your model objects).  Avoid 
 code like you see in the previous example -- we are only using it here 
 to show some extra features in TT until we get to the more advanced 
-model features we will see in Chapter 4 (see
+model features we will see in Chapter 4 (see 
 L<Catalyst::Manual::Tutorial::04_BasicCRUD/EXPLORING THE POWER OF DBIC>).
 
 Then hit "Reload" in your browser (note that you don't need to reload 

Modified: Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod
===================================================================
--- Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod	2009-10-28 00:34:02 UTC (rev 11677)
+++ Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod	2009-10-28 02:06:19 UTC (rev 11678)
@@ -183,10 +183,9 @@
 
 to get around an issue in TT v2.15 where blessed hash objects were not 
 handled correctly.  But, if you are still using v2.15, it's probably 
-time to upgrade  (v2.15 is exactly 3 years old on the day I'm typing 
-this).  If you are following along in Debian, then you should be on at 
-least v2.20.  You can test your version of Template Toolkit with the 
-following:
+time to upgrade  (v2.15 is 3.5+ years old).  If you are following 
+along in Debian, then you should be on at least v2.20.  You can test 
+your version of Template Toolkit with the following:
 
     perl -MTemplate -e 'print "$Template::VERSION\n"'
 
@@ -465,8 +464,7 @@
 the C<url_create> method because this method "chained" off C<base> and 
 specified C<:PathPart('url_create')> (note that we could have omitted 
 the "PathPart" here because it matches the name of the method, but we 
-will include it to make the logic behind the tutorial as explicit as 
-possible).
+will include it to make the logic as explicit as possible).
 
 Once again, enter the following URL into your browser:
 
@@ -518,7 +516,7 @@
 Open C<root/src/books/form_create.tt2> in your editor and enter:
 
     [% META title = 'Manual Form Book Create' -%]
-
+    
     <form method="post" action="[% c.uri_for('form_create_do') %]">
     <table>
       <tr><td>Title:</td><td><input type="text" name="title"></td></tr>
@@ -1054,7 +1052,7 @@
 you will see that the new book we added has an appropriate date and
 time entered for it (see the last line in the listing below):
 
-    sqlite3 myapp.db "select * from book"
+    $ sqlite3 myapp.db "select * from book"
     1|CCSP SNRS Exam Certification Guide|5|2009-03-08 16:26:35|2009-03-08 16:26:35
     2|TCP/IP Illustrated, Volume 1|5|2009-03-08 16:26:35|2009-03-08 16:26:35
     3|Internetworking with TCP/IP Vol.1|4|2009-03-08 16:26:35|2009-03-08 16:26:35
@@ -1073,7 +1071,7 @@
 
 =head2 Create a ResultSet Class
 
-An often overlooked but extremely powerful feature of DBIC is that it
+An often overlooked but extremely powerful features of DBIC is that it
 allows you to supply your own subclasses of C<DBIx::Class::ResultSet>.
 It allows you to pull complex and unsightly "query code" out of your
 controllers and encapsulate it in a method of your ResultSet Class.
@@ -1085,7 +1083,7 @@
 method that returns books added in the last 10 minutes.  Start by
 making a directory where DBIx::Class will look for our ResultSet Class:
 
-    mkdir lib/MyApp/Schema/ResultSet
+    $ mkdir lib/MyApp/Schema/ResultSet
 
 Then open C<lib/MyApp/Schema/ResultSet/Book.pm> and enter the following:
 
@@ -1114,7 +1112,7 @@
     
     1;
 
-Then we need to tell the Result Class to treat this as a ResultSet
+Then we need to tell the Result Class to to treat this as a ResultSet
 Class.  Open C<lib/MyApp/Schema/Result/Book.pm> and add the following
 above the "C<1;>" at the bottom of the file:
 
@@ -1323,10 +1321,10 @@
 
 The "Author(s)" column will now contain both the first and last name.
 And, because the concatenation logic was encapsulated inside our
-Result Class, it keeps the code inside our .tt template nice and clean
+Result Class, it keeps the code inside our TT template nice and clean
 (remember, we want the templates to be as close to pure HTML markup as
 possible). Obviously, this capability becomes even more useful as you
-use to remove even more complicated row-specific logic from your
+use to to remove even more complicated row-specific logic from your
 templates!
 
 
@@ -1362,10 +1360,10 @@
 return the number of authors for a book.  Open 
 C<lib/MyApp/Schema/Result/Book.pm> and add the following method:
 
-=head2 author_count
-
-Return the number of authors for the current book
-
+    =head2 author_count
+    
+    Return the number of authors for the current book
+    
     =cut
     
     sub author_count {
@@ -1415,7 +1413,7 @@
 
 Although most of the code we removed comprised comments, the overall 
 effect is dramatic... because our view code is so simple, we don't 
-need huge comments to clue people in to the gist of our code.  The view 
+huge comments to clue people in to the gist of our code.  The view 
 code is now self-documenting and readable enough that you could 
 probably get by with no comments at all.  All of the "complex" work is 
 being done in our Result Class methods (and, because we have broken 
@@ -1429,7 +1427,11 @@
 make your code cleaner, easier to write, less error-prone, and easier 
 to debug and maintain.
 
+Before you conclude this section, fire up the development server and
+hit Refresh in your browser... the output should be the same even
+though the backend code has been trimmed down.
 
+
 =head1 AUTHOR
 
 Kennedy Clark, C<hkclark at gmail.com>

Modified: Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/05_Authentication.pod
===================================================================
--- Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/05_Authentication.pod	2009-10-28 00:34:02 UTC (rev 11677)
+++ Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/05_Authentication.pod	2009-10-28 02:06:19 UTC (rev 11678)
@@ -119,6 +119,7 @@
 
     $ sqlite3 myapp.db < myapp02.sql
 
+
 =head2 Add User and Role Information to DBIC Schema
 
 Although we could manually edit the DBIC schema information to include
@@ -268,8 +269,9 @@
                     /;
 
 B<Note:> As discussed in MoreCatalystBasics, different versions of
-C<Catalyst::Devel> have used a variety of methods to load the plugins.
-You can put the plugins in the C<use Catalyst> statement if you prefer.
+C<Catalyst::Devel> have used a variety of methods to load the plugins,
+but we are going to use the current Catalyst 5.8X practice of putting
+them on the C<use Catalyst> line.
 
 The C<Authentication> plugin supports Authentication while the
 C<Session> plugins are required to maintain state across multiple HTTP
@@ -391,7 +393,7 @@
         my $password = $c->request->params->{password} || "";
     
         # If the username and password values were found in form
-        if ($username && $password) {
+        if (defined($username) && defined($password)) {
             # Attempt to log the user in
             if ($c->authenticate({ username => $username,
                                    password => $password  } )) {
@@ -489,9 +491,8 @@
 We need something that provides enforcement for the authentication
 mechanism -- a I<global> mechanism that prevents users who have not
 passed authentication from reaching any pages except the login page.
-This is generally done via an C<auto> action/method (prior to Catalyst
-v5.66, this sort of thing would go in C<MyApp.pm>, but starting in
-v5.66, the preferred location is C<lib/MyApp/Controller/Root.pm>).
+This is generally done via an C<auto> action/method in 
+C<lib/MyApp/Controller/Root.pm>.
 
 Edit the existing C<lib/MyApp/Controller/Root.pm> class file and insert
 the following method:
@@ -650,16 +651,6 @@
 easy with the Catalyst plugin Catalyst::Plugin:RequireSSL.
 
 
-=head2 Install DBIx::Class::EncodedColumn
-
-L<DBIx::Class::EncodedColumn|DBIx::Class::EncodedColumn> provides features
-that can greatly simplify the maintenance of passwords.  It's currently 
-not available as a .deb package in the normal Debian repositories, so let's
-install it directly from CPAN:
-
-    $ sudo cpan DBIx::Class::EncodedColumn
-
-
 =head2 Re-Run the DBIC::Schema Model Helper to Include DBIx::Class::EncodedColumn
 
 Next, we can re-run the model helper to have it include 
@@ -771,7 +762,9 @@
     3|test03|af929a151340c6aed4d54d7e2651795d1ad2e2f7UW8dHoGv9z|t03 at na.com|No|Go|0
 
 As you can see, the passwords are much harder to steal from the 
-database.  Also note that this demonstrates how to use a DBIx::Class 
+database (not only are the hashes stored, but every hash is different 
+even though the passwords are the same because of the added "salt" 
+value).  Also note that this demonstrates how to use a DBIx::Class 
 model outside of your web application -- a very useful feature in many 
 situations.
 
@@ -892,7 +885,7 @@
 
     __PACKAGE__->config(
             name    => 'MyApp',
-            session => {flash_to_stash => 1}
+            session => {flash_to_stash => 1},
         );
 
 B<or> add the following to C<myapp.conf>:

Modified: Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/06_Authorization.pod
===================================================================
--- Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/06_Authorization.pod	2009-10-28 00:34:02 UTC (rev 11677)
+++ Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/06_Authorization.pod	2009-10-28 02:06:19 UTC (rev 11678)
@@ -94,11 +94,6 @@
                     Session::State::Cookie
                     /;
 
-B<Note:> As discussed in MoreCatalystBasics, different versions of 
-C<Catalyst::Devel> have used a variety of methods to load the plugins. 
-You can put the plugins in the C<use Catalyst> statement if you 
-prefer.
-
 Once again (remain sharp, by now you should be getting the hang of things)
 include this additional plugin as a new dependency in the Makefile.PL file
 like this:
@@ -138,7 +133,7 @@
     </p>
 
 This code displays a different combination of links depending on the
-roles assigned to the user.
+roles assigned to the user.  
 
 
 =head2 Limit Books::add to 'admin' Users




More information about the Catalyst-commits mailing list