From: Kennedy Clark Date: Wed, 11 Mar 2009 17:03:37 +0000 (+0000) Subject: Move use of "load_namespaces" for DBIC from BasicCRUD to MoreCatalystBasics X-Git-Tag: v5.8005~181 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=commitdiff_plain;h=4ab6212da7a5e07df9837b0e57fb2b0c37aa9759;hp=4b4d38842b2383a70a54bcadb493505950b469dd Move use of "load_namespaces" for DBIC from BasicCRUD to MoreCatalystBasics Update the "Table of Contents" in Tutorial.pod to match the current sections Prep for release --- diff --git a/Changes b/Changes index f6da7d5..18b47fc 100644 --- a/Changes +++ b/Changes @@ -1,10 +1,15 @@ Revision history for Catalyst-Manual +5.7019 11 Mar 2009 - Change from the use of "part" to refer to each .pod file for the tutorial in favor of the more intuitive word "chapter." "Part" was just to ambiguous (e.g., does "prior part" refer to the prior .pod file or the prior section in the current .pod file). - - Fix typos + - Move use of "load_namespaces" for DBIC from BasicCRUD to + MoreCatalystBasics + - Update the "Table of Contents" in Tutorial.pod to match the current + sections + - Fix a few typos 5.7018 8 Mar 2009 - Add a new section to BasicCRUD covering more advanced features of diff --git a/lib/Catalyst/Manual.pm b/lib/Catalyst/Manual.pm index 95babd8..5bd01eb 100644 --- a/lib/Catalyst/Manual.pm +++ b/lib/Catalyst/Manual.pm @@ -6,6 +6,8 @@ package Catalyst::Manual; use strict; use warnings; +our $VERSION = '5.7019'; + =head1 NAME Catalyst::Manual - The Catalyst developer's manual @@ -67,6 +69,4 @@ L =cut -our $VERSION = '5.7018'; - 1; diff --git a/lib/Catalyst/Manual/Tutorial.pod b/lib/Catalyst/Manual/Tutorial.pod index 96caa8a..b9a21c3 100644 --- a/lib/Catalyst/Manual/Tutorial.pod +++ b/lib/Catalyst/Manual/Tutorial.pod @@ -153,15 +153,15 @@ CATALYST VIEWS =item * -Create a Catalyst View Using TTSite +Create a Catalyst View =item * -Globally Customize Every View +Create a TT Template Page =item * -Create a TT Template Page +Test Run The Application =back @@ -183,7 +183,35 @@ Create a Dynamic DBIC Model =item * -RUN THE APPLICATION +ENABLE THE MODEL IN THE CONTROLLER + +=over 4 + +=item * + +Test Run The Application + +=back + +=item * + +CREATE A WRAPPER FOR THE VIEW + +=over 4 + +=item * + +Configure TT.pm For The Wrapper + +=item * + +Create the Wrapper Template File and Stylesheet + +=item * + +Test Run The Application + +=back =item * @@ -199,11 +227,15 @@ Create Static DBIC Schema Files Updating the Generated DBIC Schema Files +=item * + +Run The Application + =back =item * -RUN THE APPLICATION +UPDATING THE VIEW =item * @@ -211,7 +243,7 @@ RUNNING THE APPLICATION FROM THE COMMAND LINE =item * -UPDATING THE VIEW +OPTIONAL INFORMATION =over 4 @@ -261,6 +293,22 @@ Try the url_create Feature =item * +CONVERT TO A CHAINED ACTION + +=over 4 + +=item * + +Try the Chained Action + +=item * + +Refactor to Use a "Base" Method to Start the Chains + +=back + +=item * + MANUALLY BUILDING A CREATE FORM =over 4 @@ -295,6 +343,10 @@ Include a Delete Link in the List =item * +Add a Common Method to Retrieve a Book for the Chain + +=item * + Add a Delete Action to the Controller =item * @@ -319,6 +371,34 @@ Try the Delete and Redirect With Query Param Logic =back +=item * + +EXPLORING THE POWER OF DBIC + +=over 4 + +=item * + +Add Datetime Columns to Our Existing Books Table + +=item * + +Update DBIC to Automatically Handle the Datetime Columns + +=item * + +Create a ResultSet Class + +=item * + +Chaining ResultSets + +=item * + +Adding Methods to Result Classes + +=back + =back @@ -457,23 +537,7 @@ Try Out Authentication And Authorization =item * -ENABLE ACL-BASED AUTHORIZATION - -=over 4 - -=item * - -Add the Catalyst::Plugin::Authorization::ACL Plugin - -=item * - -Add ACL Rules to the Application Class - -=item * - -Add a Method to Handle Access Violations - -=back +ENABLE MODEL-BASED AUTHORIZATION =back @@ -497,6 +561,10 @@ RUNNING CATALYST UNDER THE PERL DEBUGGER DEBUGGING MODULES FROM CPAN +=item * + +TT DEBUGGING + =back diff --git a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod index 0f7e68c..f6e098a 100644 --- a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod +++ b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod @@ -937,108 +937,6 @@ with Catalyst per se, you will almost certainly want to take advantage of them in your applications. -=head2 Convert to DBIC "load_namespaces" - -If you look back at -L you will recall that we load our DBIC Result Classes -(Books.pm, Authors.pm and BookAuthors.pm) with in -C with the C feature. Although -this method is perfectly valid, the DBIC community has migrated to a -newer C technique because it more easily supports a -variety of advanced features. Since we want to explore some of these -features below, let's first migrate our configuration over to use -C. - -If you are following along in Debian 5, you will need to upgrade your -version of -L to 0.23 -or higher. To do this, we can install directly from CPAN via the -following command: - - $ sudo cpan Catalyst::Model::DBIC::Schema - -Then make sure you are running an appropriate version: - - $ perl -MCatalyst::Model::DBIC::Schema -e \ - 'print "$Catalyst::Model::DBIC::Schema::VERSION\n"' - 0.23 - -Make sure you get version 0.23 or higher. - -B Debian will automatically "do the right thing" and use the -module we installed from CPAN and ignore the older version we picked -up via the C command. If you are using a different -environment, you will need to make sure you are using v0.23 or higher -with the command above. - -While we are at it, let's install a few other modules from CPAN for -some of the other work we will be doing below: - - $ cpan Time::Warp DBICx::TestDatabase \ - DBIx::Class::DynamicDefault DBIx::Class::TimeStamp - -Next, we need to delete the existing C so that -the Catalyst DBIC helper will recreate it. Then we re-generate -the model and schema information: - - $ rm lib/MyApp/Schema.pm - $ script/myapp_create.pl model DB DBIC::Schema MyApp::Schema \ - create=static components=TimeStamp dbi:SQLite:myapp.db - exists "/root/dev/MyApp/script/../lib/MyApp/Model" - exists "/root/dev/MyApp/script/../t" - Dumping manual schema for MyApp::Schema to directory /root/dev/MyApp/script/../lib ... - Schema dump completed. - exists "/root/dev/MyApp/script/../lib/MyApp/Model/DB.pm" - $ - $ ls lib/MyApp/Schema - Authors.pm BookAuthors.pm Books.pm Result - $ ls lib/MyApp/Schema/Result - Authors.pm BookAuthors.pm Books.pm - -Notice that we now have a duplicate set of Result Class files. With -the newer C feature, DBIC automatically looks for -your Result Class files in a subdirectory of the Schema directory -called C (the files in C were already there -from Chapter 3 of the tutorial; the files in C -are new). - -If you are using SQLite, you will need to manually re-enter the -relationship configuration as we did in Chapter 3 of the tutorial (if you -are using different database, the relationships might have been auto- -generated by Schema::Loader). One option is to use the following -command-line perl script to migrate the information across -automatically: - - $ cd lib/MyApp/Schema - $ perl -MIO::All -e 'for (@ARGV) { my $s < io($_); $s =~ s/.*\n\# You can replace.*?\n//s; - $s =~ s/'MyApp::Schema::/'MyApp::Schema::Result::/g; my $d < io("Result/$_"); - $d =~ s/1;\n?//; "$d$s" > io("Result/$_"); }' *.pm - $ cd ../../.. - -If you prefer, you can do the migration by hand using "cut and paste" -from the files in C (or from -L) -to the corresponding files in C. If you take -this approach, be sure to add C<::Result> to the end of -C in all three files (for example, in C, the -"peer class" in the C relationship needs to be changed from -C to C). - -Now we can remove the original set of Result Class files that we no -longer need: - - $ rm lib/MyApp/Schema/*.pm - $ ls lib/MyApp/Schema - Result - -Finally, test the application to be sure everything is still -working under our new configuration. Use the -C