Apply patch from Adrian Lai to clean up a few out of date bits in the tutorials
Tomas Doran [Tue, 1 Jul 2008 11:13:32 +0000 (11:13 +0000)]
lib/Catalyst/Manual/Tutorial/AdvancedCRUD/FormFu.pod
lib/Catalyst/Manual/Tutorial/Authentication.pod
lib/Catalyst/Manual/Tutorial/Authorization.pod
lib/Catalyst/Manual/Tutorial/BasicCRUD.pod
lib/Catalyst/Manual/Tutorial/Debugging.pod
lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod

index 98dd487..6cb247a 100644 (file)
@@ -239,7 +239,7 @@ Open C<root/src/books/formfu_create.tt2> in your editor and enter the following:
     [%# Render the HTML::FormFu Form %]
     [% form %]
     
-    <p><a href="[% Catalyst.uri_for('list') %]">Return to book list</a></p>
+    <p><a href="[% c.uri_for('list') %]">Return to book list</a></p>
 
 
 =head2 Add Links for Create and Update via C<HTML::FormFu>
@@ -249,7 +249,7 @@ the bottom of the existing file:
 
     <p>
       HTML::FormFu:
-      <a href="[% Catalyst.uri_for('formfu_create') %]">Create</a>
+      <a href="[% c.uri_for('formfu_create') %]">Create</a>
     </p>
 
 This adds a new link to the bottom of the book list page that we can
@@ -532,9 +532,9 @@ following:
 
     <td>
       [% # Add a link to delete a book %]
-      <a href="[% Catalyst.uri_for('delete', book.id) %]">Delete</a>
+      <a href="[% c.uri_for('delete', book.id) %]">Delete</a>
       [% # Add a link to edit a book %]
-      <a href="[% Catalyst.uri_for('formfu_edit', book.id) %]">Edit</a>
+      <a href="[% c.uri_for('formfu_edit', book.id) %]">Edit</a>
     </td>
 
 
index e66fee8..f32e05b 100644 (file)
@@ -247,7 +247,7 @@ by Catalyst under C<MyApp::Model>.
 Edit C<lib/MyApp.pm> and update it as follows (everything below
 C<StackTrace> is new):
 
-    use Catalyst qw/
+    __PACKAGE__->setup(qw/
             -Debug
             ConfigLoader
             Static::Simple
@@ -259,7 +259,7 @@ C<StackTrace> is new):
             Session
             Session::Store::FastMmap
             Session::State::Cookie
-            /;
+            /);
 
 The C<Authentication> plugin supports Authentication while the
 C<Session> plugins are required to maintain state across multiple HTTP
@@ -453,7 +453,7 @@ Create a login form by opening C<root/src/login.tt2> and inserting:
     [% META title = 'Login' %]
 
     <!-- Login form -->
-    <form method="post" action="[% Catalyst.uri_for('/login') %]">
+    <form method="post" action="[% c.uri_for('/login') %]">
       <table>
         <tr>
           <td>Username:</td>
@@ -589,9 +589,9 @@ lines to the bottom of the file:
        # This code illustrates how certain parts of the TT
        # template will only be shown to users who have logged in
     %]
-    [% IF Catalyst.user_exists %]
-        Please Note: You are already logged in as '[% Catalyst.user.username %]'.
-        You can <a href="[% Catalyst.uri_for('/logout') %]">logout</a> here.
+    [% IF c.user_exists %]
+        Please Note: You are already logged in as '[% c.user.username %]'.
+        You can <a href="[% c.uri_for('/logout') %]">logout</a> here.
     [% ELSE %]
         You need to log in to use this application.
     [% END %]
@@ -638,8 +638,8 @@ Open C<root/src/books/list.tt2> and add the following lines to the
 bottom (below the closing </table> tag):
 
     <p>
-      <a href="[% Catalyst.uri_for('/login') %]">Login</a>
-      <a href="[% Catalyst.uri_for('form_create') %]">Create</a>
+      <a href="[% c.uri_for('/login') %]">Login</a>
+      <a href="[% c.uri_for('form_create') %]">Create</a>
     </p>
 
 Reload your browser and you should now see a "Login" and "Create" links
@@ -813,7 +813,7 @@ flash vs. the C<status_msg> query parameter:
     <div id="header">[% PROCESS site/header %]</div>
 
     <div id="content">
-    <span class="message">[% status_msg || Catalyst.flash.status_msg %]</span>
+    <span class="message">[% status_msg || c.flash.status_msg %]</span>
     <span class="error">[% error_msg %]</span>
     [% content %]
     </div>
@@ -841,7 +841,7 @@ information.
 
 Although the a use of flash above is certainly an improvement over the
 C<status_msg> we employed in Part 4 of the tutorial, the C<status_msg
-|| Catalyst.flash.status_msg> statement is a little ugly. A nice
+|| c.flash.status_msg> statement is a little ugly. A nice
 alternative is to use the C<flash_to_stash> feature that automatically
 copies the content of flash to stash.  This makes your code controller
 and template code work regardless of where it was directly access, a
@@ -873,7 +873,7 @@ Restart the development server and go to
 L<http://localhost:3000/books/list> in your browser.  Delete another
 of the "Test" books you added in the previous step.  Flash should still
 maintain the status message across the redirect even though you are no
-longer explicitly accessing C<Catalyst.flash>.
+longer explicitly accessing C<c.flash>.
 
 
 =head1 AUTHOR
index f889bde..14d62b0 100644 (file)
@@ -74,7 +74,7 @@ In this section you learn how to manually configure authorization.
 
 Edit C<lib/MyApp.pm> and add C<Authorization::Roles> to the list:
 
-    use Catalyst qw/
+    __PACKAGE__->setup(qw/
             -Debug
             ConfigLoader
             Static::Simple
@@ -87,7 +87,7 @@ Edit C<lib/MyApp.pm> and add C<Authorization::Roles> to the list:
             Session
             Session::Store::FastMmap
             Session::State::Cookie
-            /;
+            /);
 
 
 =head2 Add Config Information for Authorization
@@ -145,25 +145,25 @@ C<role_relation> and C<role_field> definitions are new):
 Open C<root/src/books/list.tt2> in your editor and add the following
 lines to the bottom of the file:
 
-    <p>Hello [% Catalyst.user.username %], you have the following roles:</p>
+    <p>Hello [% c.user.username %], you have the following roles:</p>
 
     <ul>
       [% # Dump list of roles -%]
-      [% FOR role = Catalyst.user.roles %]<li>[% role %]</li>[% END %]
+      [% FOR role = c.user.roles %]<li>[% role %]</li>[% END %]
     </ul>
 
     <p>
     [% # Add some simple role-specific logic to template %]
     [% # Use $c->check_user_roles() to check authz -%]
-    [% IF Catalyst.check_user_roles('user') %]
+    [% IF c.check_user_roles('user') %]
       [% # Give normal users a link for 'logout' %]
-      <a href="[% Catalyst.uri_for('/logout') %]">Logout</a>
+      <a href="[% c.uri_for('/logout') %]">Logout</a>
     [% END %]
 
     [% # Can also use $c->user->check_roles() to check authz -%]
-    [% IF Catalyst.check_user_roles('admin') %]
+    [% IF c.check_user_roles('admin') %]
       [% # Give admin users a link for 'create' %]
-      <a href="[% Catalyst.uri_for('form_create') %]">Create</a>
+      <a href="[% c.uri_for('form_create') %]">Create</a>
     [% END %]
     </p>
 
index dcc3ade..7da68dc 100644 (file)
@@ -164,7 +164,7 @@ Edit C<root/src/books/create_done.tt2> and then enter:
     
     [% # Provide a link back to the list page                                    -%]
     [% # 'uri_for()' builds a full URI; e.g., 'http://localhost:3000/books/list' -%]
-    <p><a href="[% Catalyst.uri_for('/books/list') %]">Return to list</a></p>
+    <p><a href="[% c.uri_for('/books/list') %]">Return to list</a></p>
     
     [% # Try out the TT Dumper (for development only!) -%]
     <pre>
@@ -266,7 +266,7 @@ Open C<root/src/books/form_create.tt2> in your editor and enter:
 
     [% META title = 'Manual Form Book Create' -%]
     
-    <form method="post" action="[% Catalyst.uri_for('form_create_do') %]">
+    <form method="post" action="[% c.uri_for('form_create_do') %]">
     <table>
       <tr><td>Title:</td><td><input type="text" name="title"></td></tr>
       <tr><td>Rating:</td><td><input type="text" name="rating"></td></tr>
@@ -380,7 +380,7 @@ and 2) the four lines for the Delete link near the bottom).
         </td>
         <td>
           [% # Add a link to delete a book %]
-          <a href="[% Catalyst.uri_for('delete', book.id) %]">Delete</a>
+          <a href="[% c.uri_for('delete', book.id) %]">Delete</a>
         </td>
       </tr>
     [% END -%]
@@ -536,7 +536,7 @@ query parameter:
     <div id="header">[% PROCESS site/header %]</div>
     
     <div id="content">
-    <span class="message">[% status_msg || Catalyst.request.params.status_msg %]</span>
+    <span class="message">[% status_msg || c.request.params.status_msg %]</span>
     <span class="error">[% error_msg %]</span>
     [% content %]
     </div>
index 91ecb5a..125bc3d 100644 (file)
@@ -90,7 +90,7 @@ Then the Catalyst development server will display your message along
 with the other debug output. To accomplish the same thing in a TTSite
 view use:
 
-    [% Catalyst.log.debug("This is a test log message") %]
+    [% c.log.debug("This is a test log message") %]
 
 You can also use L<Data::Dumper|Data::Dumper> in both Catalyst code 
 (C<use Data::Dumper; $c-E<gt>log-E<gt>debug("\$var is: ".Dumper($var));)>) 
index cf413cd..aa66e12 100644 (file)
@@ -87,7 +87,7 @@ tutorial):
     $ cd MyApp
 
 This creates a similar skeletal structure to what we saw in Part 2 of 
-the tutorial, except with C<MyApp> or C<myapp> substituted for 
+the tutorial, except with C<MyApp> and C<myapp> substituted for 
 C<Hello> and C<hello>.
 
 
@@ -181,17 +181,17 @@ To modify the list of plugins, edit C<lib/MyApp.pm> (this file is
 generally referred to as your I<application class>) and delete the line
 with:
 
-    use Catalyst qw/-Debug ConfigLoader Static::Simple/;
+    __PACKAGE__->setup(qw/-Debug ConfigLoader Static::Simple/);
 
 Replace it with:
 
-    use Catalyst qw/
+    __PACKAGE__->setup(qw/
             -Debug
             ConfigLoader
             Static::Simple
             
             StackTrace
-            /;
+            /);
 
 This tells Catalyst to start using one new plugin:
 
@@ -361,30 +361,12 @@ directories that can be used to customize the look and feel of your
 application.  Also take a look at C<lib/MyApp/View/TT.pm> for config
 values set by the C<TTSite> helper.
 
-B<TIP>: Note that TTSite does one thing that could confuse people who
-are used to the normal C<TT> Catalyst view: it redefines the Catalyst
-context object in templates from its usual C<c> to C<Catalyst>. When
-looking at other Catalyst examples, remember that they almost always use
-C<c>.  Note that Catalyst and TT I<do not complain> when you use the
-wrong name to access the context object...TT simply outputs blanks for
-that bogus logic (see next tip to change this behavior with TT C<DEBUG>
-options).  Finally, be aware that this change in name I<only>
-applies to how the context object is accessed inside your TT templates;
-your controllers will continue to use C<$c> (or whatever name you use
-when fetching the reference from C<@_> inside your methods). (You can
-change back to the "default" behavior be removing the C<CATALYST_VAR>
-line from C<lib/MyApp/View/TT.pm>, but you will also have to edit
-C<root/lib/config/main> and C<root/lib/config/url>.  If you do this, be
-careful not to have a collision between your own C<c> variable and the
-Catalyst C<c> variable.)
-
 B<TIP>: When troubleshooting TT it can be helpful to enable variable
 C<DEBUG> options.  You can do this in a Catalyst environment by adding
 a C<DEBUG> line to the C<__PACKAGE__->config> declaration in 
 C<lib/MyApp/View/TT.pm>:
 
     __PACKAGE__->config({
-        CATALYST_VAR => 'Catalyst',
         ...
         DEBUG        => 'undef',
         ...