Enter the following command to enable the C<TT> style of view
rendering for this tutorial:
- $ script/myapp_create.pl view TT TT
+ $ script/myapp_create.pl view HTML TT
exists "/home/me/MyApp/script/../lib/MyApp/View"
exists "/home/me/MyApp/script/../t"
- created "/home/me/MyApp/script/../lib/MyApp/View/TT.pm"
- created "/home/me/MyApp/script/../t/view_TT.t"
-
-This simply creates a view called C<TT> (the second 'TT' argument) in
-a file called C<TT.pm> (the first 'TT' argument). It is now up to you
-to decide how you want to structure your view layout. For the
-tutorial, we will start with a very simple TT template to initially
-demonstrate the concepts, but quickly migrate to a more typical
-"wrapper page" type of configuration (where the "wrapper" controls the
-overall "look and feel" of your site from a single file or set of
-files).
-
-Edit C<lib/MyApp/View/TT.pm> and you should see that the default
+ created "/home/me/MyApp/script/../lib/MyApp/View/HTML.pm"
+ created "/home/me/MyApp/script/../t/view_HTML.t"
+
+This simply creates a view called C<HTML> in a file called C<HTML.pm> (the first
+argument). It is now up to you to decide how you want to structure your view
+layout. For the tutorial, we will start with a very simple TT template to
+initially demonstrate the concepts, but quickly migrate to a more typical
+"wrapper page" type of configuration (where the "wrapper" controls the overall
+"look and feel" of your site from a single file or set of files).
+
+Edit C<lib/MyApp/View/HTML.pm> and you should see that the default
contents contains something similar to the following:
__PACKAGE__->config(TEMPLATE_EXTENSION => '.tt');
$ perl -MCatalyst::Model::DBIC::Schema -e \
'print "$Catalyst::Model::DBIC::Schema::VERSION\n"'
- 0.39
+ 0.4
Please note the '\' above. Depending on your environment, you might
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 have less than v0.39, you will need to run this command to
-install it directly from CPAN:
+If you are following along in Debian 5, you should have version 0.40 or
+higher (shown above as "0.4" with the tailing zero removed). If you have
+less than v0.39, you will need to run this command to install it
+directly from CPAN:
$ sudo cpan Catalyst::Model::DBIC::Schema
B<NOTE:> Older versions of
L<Catalyst::Model::DBIC::Schema|Catalyst::Model::DBIC::Schema> use the
deprecated DBIx::Class C<load_classes> technique instead of the newer
-C<load_namspaces>. For new applications, please try to use
+C<load_namespaces>. For new applications, please try to use
C<load_namespaces> since it more easily supports a very useful DBIC
technique called "ResultSet Classes." If you need to convert an
existing application from "load_classes" to "load_namespaces," you can
$ export DBIC_TRACE=1
$ script/myapp_server.pl -r
-
+
This assumes you are using bash as your shell -- adjust accordingly if
you are using a different shell (for example, under tcsh, use
C<setenv DBIC_TRACE 1>).
| MyApp::Model::DB::Author | class |
| MyApp::Model::DB::Book | class |
| MyApp::Model::DB::BookAuthor | class |
- | MyApp::View::TT | instance |
+ | MyApp::View::HTML | instance |
'-----------------------------------------------------------------+----------'
[debug] Loaded Private actions:
edit many individual files.
-=head2 Configure TT.pm For The Wrapper
+=head2 Configure HTML.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.
-Edit you TT view in C<lib/MyApp/View/TT.pm> and change it to match the
+Edit you TT view in C<lib/MyApp/View/HTML.pm> and change it to match the
following:
__PACKAGE__->config(
Hit "Reload" in your web browser and you should now see a formatted
version of our basic book list. (Again, the development server should
have automatically restarted when you made changes to
-C<lib/MyApp/View/TT.pm>. If you are not using the "-r" option, you will
+C<lib/MyApp/View/HTML.pm>. If you are not using the "-r" option, you will
need to hit C<Ctrl-C> and manually restart it. Also note that the
development server does I<NOT> need to restart for changes to the TT and
static files we created and edited in the C<root> directory -- those
{ join_type => "LEFT" },
);
-
The arguments are similar, but see
L<DBIx::Class::Relationship/belongs_to> for the details.
-
+
Although recent versions of SQLite and L<DBIx::Class::Schema::Loader>
automatically handle the C<has_many> and C<belongs_to> relationships,
C<many_to_many> relationships currently need to be manually inserted.
The C<many_to_many> relationship is optional, but it makes it
easier to map a book to its collection of authors. Without
-it, we would have to "walk" though the C<book_author> table as in
+it, we would have to "walk" through the C<book_author> table as in
C<$book-E<gt>book_author-E<gt>first-E<gt>author-E<gt>last_name> (we
will see examples on how to use DBIx::Class objects in your code soon,
but note that because C<$book-E<gt>book_author> can return multiple
Run the Catalyst development server script with the C<DBIC_TRACE> option
(it might still be enabled from earlier in the tutorial, but here is an
-alternate way to specify the option just in case):
+alternate way to specify the trace option just in case):
$ DBIC_TRACE=1 script/myapp_server.pl -r
Result Classes we created).
Then hit the URL L<http://localhost:3000/books/list> with your browser
-and be sure that the book list still displays correctly. You can leave
-the development server running for the next step if you wish.
+and be sure that the book list still displays correctly.
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
$c->stash(template => 'books/list.tt2');
Then delete the C<TEMPLATE_EXTENSION> line in
-C<lib/MyApp/View/TT.pm>.
+C<lib/MyApp/View/HTML.pm>.
Check the L<http://localhost:3000/books/list> URL in your browser.
It should look the same manner as with earlier sections.
most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/>.
-Copyright 2006-2008, Kennedy Clark, under Creative Commons License
+Copyright 2006-2010, Kennedy Clark, under Creative Commons License
(L<http://creativecommons.org/licenses/by-sa/3.0/us/>).