X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FBasicCRUD.pod;h=f8aef9a9ea4accf57c5f1367b1e95cf01501bccf;hb=b3c640cce0888c99072a7c18de983e075407a493;hp=f6685ecddab6c6c89f553e33474a6592efe9cea6;hpb=64ccd8a8bfbc16276c044c94702b1440c2897695;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod index f6685ec..f8aef9a 100644 --- a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod +++ b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod @@ -56,7 +56,7 @@ L This part of the tutorial builds on the fairly primitive application created in Part 2 to add basic support for Create, Read, Update, and Delete (CRUD) of C objects. Note that the 'list' function in Part -2 already implements the Read portion of Crud (although Read normally +2 already implements the Read portion of CRUD (although Read normally refers to reading a single object; you could implement full read functionality using the techniques introduced below). This section will focus on the Create and Delete aspects of CRUD. More advanced @@ -71,7 +71,6 @@ following command: IMPORTANT: Does not work yet. Will be completed for final version. - =head1 FORMLESS SUBMISSION Our initial attempt at object creation will utilize the "URL arguments" @@ -85,21 +84,22 @@ Edit C and enter the following method: =head2 url_create - Create a book with the supplied title, rating and author + Create a book with the supplied title, rating, and author =cut sub url_create : Local { - # In addition to self & context, get the title, rating & 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 @@ -141,40 +141,45 @@ 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 -%] [% # 'uri_for()' builds a full URI; e.g., 'http://localhost:3000/books/list' -%]

Return to list

- [% # Try out the TT Dumper -%] + [% # Try out the TT Dumper (for development only!) -%]
     Dump of the 'book' variable:
     [% Dumper.dump(book) %]
     
-The TT C directive allows access to a variety of plugin modules (we -are talking TT plugins here, not Catalyst plugins) to add extra -functionality to the base TT capabilities. Here, the plugin allows -L "pretty printing" of objects and variables. -Other than that, the rest of the code should be familiar from the -examples in Part 2. +The TT C directive allows access to a variety of plugin modules (TT +plugins, that is, not Catalyst plugins) to add extra functionality to +the base TT capabilities. Here, the plugin allows L +"pretty printing" of objects and variables. Other than that, the rest +of the code should be familiar from the examples in Part 2. B As mentioned earlier, the C view class created by TTSite redefines the name used to access the Catalyst context object in TT templates from the usual C to C. - =head2 Try the C Feature If the application is still running from before, use C to kill -it. Then restart the server: +it. Then restart the server: $ script/myapp_server.pl @@ -184,7 +189,7 @@ output. B: You can use C