X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FBasicCRUD.pod;h=6c8e4308c6d2eece8e37a423c2b814127d7c5a82;hb=292eba91f41f6be26c6f432293a39b0ea938429d;hp=296f0b71afd1fd0018e7ba677910815f0e2d02d3;hpb=71dedf57db8d0813e63bcfc3fc3b60b469cf81a8;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod index 296f0b7..6c8e430 100644 --- a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod +++ b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod @@ -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 checkout http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial -r 4611 . =head1 FORMLESS SUBMISSION @@ -93,14 +92,13 @@ Edit C and enter the following method: # author_id args from the URL. Note that Catalyst automatically # puts extra information after the "//model('MyAppDB::Book')->create({ - title => $title, - rating => $rating + title => $title, + rating => $rating }); # Add a record to the join table for this book, mapping to @@ -142,12 +140,19 @@ Edit C and then enter: [% # optional, but prevents "massive indenting" of deeply nested objects -%] [% USE Dumper(Indent=1) -%] - [% # Set the page title -%] + [% # Set the page title. META can 'go back' and set values in templates -%] + [% # that have been processed 'before' this template (here it's for -%] + [% # root/lib/site/html and root/lib/site/header). Note that META on -%] + [% # 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 %]' + [% # of 'first' to only list the first author (if > 1 author). TT -%] + [% # v2.15 has an issue that requires -%] + [% # 'book.authors.list.first.value.last_name' vs. the shorter -%] + [% # 'book.authors.first.last_name' in prior versions. -%] +

Added book '[% book.title %]' + by '[% book.authors.list.first.value.last_name %]' with a rating of [% book.rating %].

[% # Provide a link back to the list page -%] @@ -235,7 +240,7 @@ This action simply invokes a view containing a book creation form. Open C in your editor and enter: - [% META title = 'Book Create' -%] + [% META title = 'Manual Form Book Create' -%]
@@ -334,16 +339,16 @@ and 2) the four lines for the Delete link near the bottom).
[% book.title %] [% book.rating %] - [% # Print author count in parens. 'book.authors' uses the 'many_to_many' -%] - [% # relationship to retrieve all of the authors of a book. 'size' is a -%] - [% # TT VMethod to get the number of elements in a list. -%] - ([% book.authors.size %]) - [% # Use an alternate form of a FOREACH loop to display authors. -%] - [% # _ below is the TT string concatenation operator. -%] - [% author.last_name _' ' FOREACH author = book.authors %] - [% # Note: if many_to_many relationship not used in Authors.pm, you could -%] - [% # have used the following to 'walk' through the 'join table objects' -%] - [% # bk_author.author.last_name _' ' FOREACH bk_author = book.book_authors %] + [% # 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. -%] + [% tt_authors = [ ]; + xx = 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 -%] + [% tt_authors.join(', ') %] [% # Add a link to delete a book %] @@ -362,7 +367,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 @@ -420,14 +425,15 @@ 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 Catlayst Tutorial can be found at +L. Copyright 2006, Kennedy Clark, under Creative Commons License (L). -Version: .94 -