[Catalyst-commits] r10284 - Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial

hkclark at dev.catalyst.perl.org hkclark at dev.catalyst.perl.org
Tue May 26 02:45:27 GMT 2009


Author: hkclark
Date: 2009-05-26 02:45:27 +0000 (Tue, 26 May 2009)
New Revision: 10284

Modified:
   Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod
   Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/05_Authentication.pod
   Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/06_Authorization.pod
   Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/08_Testing.pod
Log:
Finish review for depluralization and related updates

Modified: Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod
===================================================================
--- Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod	2009-05-26 01:04:34 UTC (rev 10283)
+++ Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod	2009-05-26 02:45:27 UTC (rev 10284)
@@ -1066,9 +1066,9 @@
 Notice in the debug log that the SQL DBIC generated has changed to
 incorporate the datetime logic:
 
-    INSERT INTO book ( created, rating, title, updated) VALUES ( ?, ?, ?, ? ): 
+    INSERT INTO book ( created, rating, title, updated ) VALUES ( ?, ?, ?, ? ): 
     '2009-05-25 20:39:41', '5', 'TCPIP_Illustrated_Vol-2', '2009-05-25 20:39:41'
-    INSERT INTO book_author ( author_id, book_id) VALUES ( ?, ? ): '4', '10'
+    INSERT INTO book_author ( author_id, book_id ) VALUES ( ?, ? ): '4', '10'
 
 
 =head2 Create a ResultSet Class

Modified: Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/05_Authentication.pod
===================================================================
--- Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/05_Authentication.pod	2009-05-26 01:04:34 UTC (rev 10283)
+++ Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/05_Authentication.pod	2009-05-26 02:45:27 UTC (rev 10284)
@@ -159,7 +159,7 @@
     #     1) Name of relationship, DBIC will create accessor with this name
     #     2) Name of the model class referenced by this relationship
     #     3) Column name in *foreign* table (aka, foreign key in peer table)
-    __PACKAGE__->has_many(map_user_role => 'MyApp::Schema::Result::UserRole', 'user_id');
+    __PACKAGE__->has_many(map_user_roles => 'MyApp::Schema::Result::UserRole', 'user_id');
     
     # many_to_many():
     #   args:
@@ -167,7 +167,7 @@
     #     2) Name of has_many() relationship this many_to_many() is shortcut for
     #     3) Name of belongs_to() relationship in model class of has_many() above
     #   You must already have the has_many() defined to use a many_to_many().
-    __PACKAGE__->many_to_many(roles => 'map_user_role', 'role');
+    __PACKAGE__->many_to_many(roles => 'map_user_roles', 'role');
 
 
 C<lib/MyApp/Schema/Result/Role.pm>:
@@ -181,7 +181,7 @@
     #     1) Name of relationship, DBIC will create accessor with this name
     #     2) Name of the model class referenced by this relationship
     #     3) Column name in *foreign* table (aka, foreign key in peer table)
-    __PACKAGE__->has_many(map_user_role => 'MyApp::Schema::Result::UserRole', 'role_id');
+    __PACKAGE__->has_many(map_user_roles => 'MyApp::Schema::Result::UserRole', 'role_id');
 
 
 C<lib/MyApp/Schema/Result/UserRole.pm>:
@@ -253,7 +253,8 @@
 C<StackTrace> is new):
 
     # Load plugins
-    use Catalyst qw/-Debug
+    use Catalyst qw/
+                    -Debug
                     ConfigLoader
                     Static::Simple
     
@@ -745,13 +746,21 @@
 
 Then run the following command:
 
-    $ perl -Ilib set_hashed_passwords.pl
+    $ DBIC_TRACE=1 perl -Ilib set_hashed_passwords.pl
 
 We had to use the C<-Ilib> arguement to tell perl to look under the 
 C<lib> directory for our C<MyApp::Schema> model.
 
-Then dump the users table to verify that it worked:
+The DBIC_TRACE output should show that the update worked:
 
+    $ DBIC_TRACE=1 perl -Ilib set_hashed_passwords.pl
+    SELECT me.id, me.username, me.password, me.email_address, me.first_name, me.last_name, me.active FROM user me: 
+    UPDATE user SET password = ? WHERE ( id = ? ): 'oXiyAcGOjowz7ISUhpIm1IrS8AxSZ9r4jNjpX9VnVeQmN6GRtRKTz', '1'
+    UPDATE user SET password = ? WHERE ( id = ? ): 'PmyEPrkB8EGwvaF/DvJm7LIfxoZARjv8ygFIR7pc1gEA1OfwHGNzs', '2'
+    UPDATE user SET password = ? WHERE ( id = ? ): 'h7CS1Fm9UCs4hjcbu2im0HumaHCJUq4Uriac+SQgdUMUfFSoOrz3c', '3'
+
+But we can further confirm our actions by dumping the users table:
+
     $ sqlite3 myapp.db "select * from user"
     1|test01|38d3974fa9e9263099f7bc2574284b2f55473a9bM=fwpX2NR8|t01 at na.com|Joe|Blow|1
     2|test02|6ed8586587e53e0d7509b1cfed5df08feadc68cbMJlnPyPt0I|t02 at na.com|Jane|Doe|1

Modified: Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/06_Authorization.pod
===================================================================
--- Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/06_Authorization.pod	2009-05-26 01:04:34 UTC (rev 10283)
+++ Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/06_Authorization.pod	2009-05-26 02:45:27 UTC (rev 10284)
@@ -79,7 +79,8 @@
 Edit C<lib/MyApp.pm> and add C<Authorization::Roles> to the list:
 
     # Load plugins
-    use Catalyst qw/-Debug
+    use Catalyst qw/
+                    -Debug
                     ConfigLoader
                     Static::Simple
                 
@@ -107,6 +108,7 @@
         'Catalyst::Plugin::Authorization::Roles' => '0',
     );
 
+
 =head2 Add Role-Specific Logic to the "Book List" Template
 
 Open C<root/src/books/list.tt2> in your editor and add the following
@@ -117,7 +119,7 @@
     
     <ul>
       [% # Dump list of roles -%]
-      [% FOR role = c.user.role %]<li>[% role %]</li>[% END %]
+      [% FOR role = c.user.roles %]<li>[% role %]</li>[% END %]
     </ul>
     
     <p>
@@ -175,9 +177,9 @@
     
             # Add a record to the join table for this book, mapping to
             # appropriate author
-            $book->add_to_book_author({author_id => $author_id});
+            $book->add_to_book_authors({author_id => $author_id});
             # Note: Above is a shortcut for this:
-            # $book->create_related('book_author', {author_id => $author_id});
+            # $book->create_related('book_authors', {author_id => $author_id});
     
             # Assign the Book object to the stash for display in the view
             $c->stash->{book} = $book;
@@ -305,7 +307,7 @@
     
         # Redirect the user back to the list page
         $c->response->redirect($c->uri_for($self->action_for('list')));
-    }    
+    }
 
 Here, we C<detach> to an error page if the user is lacking the 
 appropriate permissions.  For this to work, we need to make 

Modified: Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/08_Testing.pod
===================================================================
--- Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/08_Testing.pod	2009-05-26 01:04:34 UTC (rev 10283)
+++ Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/08_Testing.pod	2009-05-26 02:45:27 UTC (rev 10284)
@@ -237,7 +237,12 @@
     # Log in as each user
     # Specify username and password on the URL
     $ua1->get_ok("http://localhost/login?username=test01&password=mypass", "Login 'test01'");
-    $ua1->get_ok("http://localhost/login?username=test02&password=mypass", "Login 'test02'");
+    # Could make user2 like user1 above, but use the form to show another way
+    $ua2->submit_form(
+        fields => {
+            username => 'test02',
+            password => 'mypass',
+        });
     
     # Go back to the login page and it should show that we are already logged in
     $_->get_ok("http://localhost/login", "Return to '/login'") for $ua1, $ua2;




More information about the Catalyst-commits mailing list