From: Kennedy Clark
Date: Tue, 24 Feb 2009 02:52:47 +0000 (+0000)
Subject: Misc updates in support of moving to Chained
X-Git-Tag: v5.8005~206
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=commitdiff_plain;h=e075db0c03ded5b1d100852f9ba9c040e2499109
Misc updates in support of moving to Chained
---
diff --git a/lib/Catalyst/Manual/Tutorial/AdvancedCRUD/FormFu.pod b/lib/Catalyst/Manual/Tutorial/AdvancedCRUD/FormFu.pod
index 80c872c..03d9273 100644
--- a/lib/Catalyst/Manual/Tutorial/AdvancedCRUD/FormFu.pod
+++ b/lib/Catalyst/Manual/Tutorial/AdvancedCRUD/FormFu.pod
@@ -156,7 +156,7 @@ following method:
# Set a status message for the user
$c->flash->{status_msg} = 'Book created';
# Return to the books list
- $c->response->redirect($c->uri_for('list'));
+ $c->response->redirect($c->uri_for($self->action_for('list')));
$c->detach;
} else {
# Get the authors from the DB
@@ -260,7 +260,7 @@ Open C in your editor and enter the following:
[%# Render the HTML::FormFu Form %]
[% form %]
-
This adds a new link to the bottom of the book list page that we can
@@ -473,7 +473,7 @@ bottom:
# Make sure we were able to get a book
unless ($book) {
$c->flash->{error_msg} = "Invalid book -- Cannot edit";
- $c->response->redirect($c->uri_for('list'));
+ $c->response->redirect($c->uri_for($self->action_for('list')));
$c->detach;
}
@@ -489,7 +489,7 @@ bottom:
# Set a status message for the user
$c->flash->{status_msg} = 'Book edited';
# Return to the books list
- $c->response->redirect($c->uri_for('list'));
+ $c->response->redirect($c->uri_for($self->action_for('list')));
$c->detach;
} else {
# Get the authors from the DB
@@ -553,9 +553,9 @@ following:
...
[% # Add a link to delete a book %]
- Delete
+ Delete
[% # Add a link to edit a book %]
- Edit
+ Edit
...
diff --git a/lib/Catalyst/Manual/Tutorial/Authentication.pod b/lib/Catalyst/Manual/Tutorial/Authentication.pod
index 63c346c..d8c4978 100644
--- a/lib/Catalyst/Manual/Tutorial/Authentication.pod
+++ b/lib/Catalyst/Manual/Tutorial/Authentication.pod
@@ -417,7 +417,7 @@ and partly for code clarity) only to use C in
C, and then mainly to generate the 404 not
found page for the application.
-Instead, we are using C here to
+Instead, we are using C here to
specifically match the URL C. C actions (aka, "literal
actions") create URI matches relative to the namespace of the
controller where they are defined. Although C supports
@@ -525,36 +525,42 @@ the following method:
}
-B Catalyst provides a number of different types of actions,
-such as C, C, C and the new C. You
-should refer to L for
-a more detailed explanation, but the following bullet points provide a
-quick introduction:
+B Catalyst provides a number of different types of actions,
+such as C, C, C, C and C. You
+should refer to L for a more
+detailed explanation, but the following bullet points provide a quick
+introduction:
=over 4
=item *
-The majority of applications have traditionally used C actions
-for items that respond to user requests and C actions for
-those that do not directly respond to user input.
+In the past, the majority of applications have traditionally used
+C actions for items that respond to user requests and
+C actions for those that do not directly respond to user
+input.
=item *
-Newer Catalyst applications tend to use C actions and the
-C attribute because of their power and flexibility. You can
-specify the path to match relative to the namespace of the current
-module as an argument to C. For example C in
-C would match on the URL
-C but C would
-match on C.
+As discussed in Part 4 of the tutorial, newer Catalyst applications
+tend to use the Chained dispatch form of action types because of its
+power and flexibility. See
+L
+and
+L
+for more information on chained actions.
=item *
-Automatic "chaining" of actions by the dispatcher is a powerful
-feature that allows multiple methods to handle a single URL. See
-L
-for more information on chained actions.
+C actions provide a limited subset of what can be found done
+with Chained actions. You can match on different portions of the URI
+(for example C in C would
+match on the URL C but
+C would match on C). You
+can also specify the number of arguments to match via C much
+like the endpoint of a chain. However, becaused Chained actions offer
+these features and so much more (at the expense of some additional
+complexity), Chained action types are generally recommened.
=item *
diff --git a/lib/Catalyst/Manual/Tutorial/Authorization.pod b/lib/Catalyst/Manual/Tutorial/Authorization.pod
index d340d20..b59facf 100644
--- a/lib/Catalyst/Manual/Tutorial/Authorization.pod
+++ b/lib/Catalyst/Manual/Tutorial/Authorization.pod
@@ -162,13 +162,13 @@ lines to the bottom of the file:
[% # Use $c->check_user_roles() to check authz -%]
[% IF c.check_user_roles('user') %]
[% # Give normal users a link for 'logout' %]
- Logout
+ User Logout
[% END %]
[% # Can also use $c->user->check_roles() to check authz -%]
[% IF c.check_user_roles('admin') %]
[% # Give admin users a link for 'create' %]
- Create
+ Admin Create
[% END %]
@@ -195,7 +195,7 @@ updating C to match the following code:
=cut
- sub url_create : Local {
+ sub url_create :Chained('base') :PathPart('url_create') :Args(3) {
# In addition to self & context, get the title, rating & author_id args
# from the URL. Note that Catalyst automatically puts extra information
# after the "// to match the following code:
# Set the TT template to use
$c->stash->{template} = 'books/create_done.tt2';
} else {
- # Provide very simple feedback to the user
+ # Provide very simple feedback to the user.
$c->response->body('Unauthorized!');
}
}
@@ -244,12 +244,12 @@ way to demonstrate that TT templates will not be used if the response
body has already been set. In reality you would probably want to use a
technique that maintains the visual continuity of your template layout
(for example, using the "status" or "error" message feature added in
-Part 3).
+Part 3 or C to an action that shows an "unauthorized" page).
B: If you want to keep your existing C method, you can
create a new copy and comment out the original by making it look like a
-Pod comment. For example, put something like C<=begin> before C and C<=end> after the closing C<}>.
+Pod comment. For example, put something like C<=begin> before
+C and C<=end> after the closing C<}>.
=head2 Try Out Authentication And Authorization
@@ -408,7 +408,7 @@ Then run the Catalyst development server script:
Log in as C. Once at the book list, click the "Create" link
to try the C action. You should receive a red
"Unauthorized!" error message at the top of the list. (Note that in
-the example code the "Create" link code in C
+the example code the "Admin Create" link code in C
is inside an C statement that only displays the list to
admin-level users.) If you log in as C you should be able to
view the C form and add a new book.
diff --git a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod
index 78db797..d636da4 100644
--- a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod
+++ b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod
@@ -1,4 +1,4 @@
-=head1 NAME
+ =head1 NAME
Catalyst::Manual::Tutorial::BasicCRUD - Catalyst Tutorial - Part 4: Basic CRUD
@@ -620,7 +620,7 @@ and 2) the four lines for the Delete link near the bottom).
[% # Add a link to delete a book %]
- Delete
+ Delete
[% END -%]
@@ -663,6 +663,13 @@ operate on an existing book can chain directly off base.
To add the C