X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FBasicCRUD.pod;h=493c8685852bf2ee36e9f1967fcd17523f78a7e3;hp=6a6ab1bde1bacf32da714ad84584d3fe3b2b98d3;hb=c9b77c06a0de97f1d6e9a66091e693a637578357;hpb=5c1f2a06b0fc9129364231cbf7d530cde86abb7b diff --git a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod index 6a6ab1b..493c868 100644 --- a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod +++ b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod @@ -45,7 +45,7 @@ L =item 9 -L +L =back @@ -67,8 +67,7 @@ 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@### - IMPORTANT: Does not work yet. Will be completed for final version. + svn co http://dev.catalyst.perl.org/repos/Catalyst/tags/examples/Tutorial/5.7X/BasicCRUD MyApp =head1 FORMLESS SUBMISSION @@ -147,9 +146,19 @@ Edit C and then enter: [% # simple strings (e.g., no variable interpolation). -%] [% META title = 'Book Created' %] - [% # Output information about the record that was added. Note use -%] - [% # of 'first' to only list the first author (if > 1 author). -%] -

Added book '[% book.title %]' by '[% book.authors.first.last_name %]' + [% # Output information about the record that was added. First title. -%] +

Added book '[% book.title %]' + + [% # Output the last name of the first author. This is complicated by an -%] + [% # issue in TT 2.15 where blessed hash objects are not handled right. -%] + [% # First, fetch 'book.authors' from the DB once. -%] + [% authors = book.authors %] + [% # Now use IF statements to test if 'authors.first' is "working". If so, -%] + [% # we use it. Otherwise we use a hack that seems to keep TT 2.15 happy. -%] + by '[% authors.first.last_name IF authors.first; + authors.list.first.value.last_name IF ! authors.first %]' + + [% # Output the rating for the book that was added -%] with a rating of [% book.rating %].

[% # Provide a link back to the list page -%] @@ -254,7 +263,7 @@ C, the method created in the section that follows. =head2 Add Method to Process Form Values and Update Database Edit C and add the following method to -save the form information to the databse: +save the form information to the database: =head2 form_create_do @@ -338,13 +347,16 @@ and 2) the four lines for the Delete link near the bottom). [% # 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 are making a bogus assignment to -%] - [% # the 'xx' 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 = [ ]; - xx = 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 -%] ([% tt_authors.size %]) - [% # Use another TT virtual method to join the names with comma separators -%] + [% # Use another TT vmethod to join & print the names & comma separators -%] [% tt_authors.join(', ') %] @@ -364,7 +376,7 @@ will be used instead of full HTML buttons). Open C in your editor and add the following method: - =head2 Delete + =head2 delete Delete a book @@ -422,11 +434,14 @@ the "Delete" link next to "TCPIP_Illustrated_Vol-2". A green "Book deleted" status message should display at the top of the page, along with a list of the six remaining books. + =head1 AUTHOR Kennedy Clark, C -Please report any errors, issues or suggestions to the author. +Please report any errors, issues or suggestions to the author. The +most recent version of the Catalyst Tutorial can be found at +L. Copyright 2006, Kennedy Clark, under Creative Commons License (L).