X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2F04_BasicCRUD.pod;h=f84c3d743e284df29e30917c3d608450f46be53c;hp=43c59689e5e1e0a6428a0ec78e81ef3855c33e65;hb=b6e53c1ca5bfa271bfce99e0f42a56c8fd4df4be;hpb=3dba69ab41309af0fd011b762cc53cd90c61ff96 diff --git a/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod b/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod index 43c5968..f84c3d7 100644 --- a/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod +++ b/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod @@ -75,8 +75,9 @@ of tool to automate the process. You get less control, but it can be quick and easy. For example, see L, L, and L. -You can check out the source code for this example from the Catalyst -Subversion repository as per the instructions in +Source code for the tutorial in included in the F +directory of the Tutorial Virtual machine (one subdirectory per +chapter). There are also instructions for downloading the code in L. @@ -787,9 +788,10 @@ cascading delete operation via the DBIC_TRACE output: SELECT me.id, me.title, me.rating FROM book me WHERE ( ( me.id = ? ) ): '6' DELETE FROM book WHERE ( id = ? ): '6' - SELECT me.book_id, me.author_id FROM book_author me WHERE ( me.book_id = ? ): '6' - DELETE FROM book_author WHERE ( author_id = ? AND book_id = ? ): '4', '6' +If you get the error C then you +probably forgot to uncomment the template line in C at the end of +chapter 3. =head2 Fixing a Dangerous URL @@ -897,7 +899,10 @@ query parameter: Although the sample above only shows the C div, leave the rest of the file intact -- the only change we made to the C was to add "C<|| c.request.params.status_msg>" to the -Cspan class="message"E> line. +Cspan class="message"E> line. Note that we definitely want +the "C<| html>" TT filter here since it would be easy for users to +modify the message on the URL and possibly inject harmful code into the +application if we left that off. =head2 Try the Delete and Redirect With Query Param Logic @@ -943,6 +948,15 @@ book was added and when each book is updated: sqlite> .quit $ +Here are the commands without the surrounding sqlite3 prompt and output +in case you want to cut and paste them as a single block (but still +start sqlite3 before you paste these in): + + ALTER TABLE book ADD created TIMESTAMP; + ALTER TABLE book ADD updated TIMESTAMP; + UPDATE book SET created = DATETIME('NOW'), updated = DATETIME('NOW'); + SELECT * FROM book; + This will modify the C table to include the two new fields and populate those fields with the current time. @@ -955,11 +969,11 @@ the new fields: $ script/myapp_create.pl model DB DBIC::Schema MyApp::Schema \ create=static components=TimeStamp dbi:SQLite:myapp.db \ on_connect_do="PRAGMA foreign_keys = ON" - 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 ... + exists "/home/catalyst/dev/MyApp/script/../lib/MyApp/Model" + exists "/home/catalyst/dev/MyApp/script/../t" + Dumping manual schema for MyApp::Schema to directory /home/catalyst/dev/MyApp/script/../lib ... Schema dump completed. - exists "/root/dev/MyApp/script/../lib/MyApp/Model/DB.pm" + exists "/home/catalyst/dev/MyApp/script/../lib/MyApp/Model/DB.pm" Notice that we modified our use of the helper slightly: we told it to include the L in the C line of @@ -971,11 +985,11 @@ call to C. However, also notice that the C relationships we manually added below the "C<# DO NOT MODIFY...>" line were automatically preserved. -While we have this file open, let's update it with some additional -information to have DBIC automatically handle the updating of these two -fields for us. Insert the following code at the bottom of the file (it -B be B the "C<# DO NOT MODIFY...>" line and B the -C<1;> on the last line): +While we C open, let's update it with +some additional information to have DBIC automatically handle the +updating of these two fields for us. Insert the following code at the +bottom of the file (it B be B the "C<# DO NOT MODIFY...>" +line and B the C<1;> on the last line): # # Enable automatic date handling @@ -1377,17 +1391,18 @@ output should be the same even though the backend code has been trimmed down. +You can jump to the next chapter of the tutorial here: +L + + =head1 AUTHOR Kennedy Clark, C Feel free to contact the author for any errors or suggestions, but the best way to report issues is via the CPAN RT Bug system at -. - -The most recent version of the Catalyst Tutorial can be found at -L. +L. -Copyright 2006-2010, Kennedy Clark, under the +Copyright 2006-2011, Kennedy Clark, under the Creative Commons Attribution Share-Alike License Version 3.0 (L).