rollback to use Catalyst qw/@plugins/
[catagits/Catalyst-Manual.git] / lib / Catalyst / Manual / Cookbook.pod
index 6ad8555..c39e0a5 100644 (file)
@@ -10,21 +10,23 @@ Yummy code like your mum used to bake!
 
 =head1 Basics
 
-These recipes cover some basic stuff that is worth knowing for catalyst developers.
+These recipes cover some basic stuff that is worth knowing for
+catalyst developers.
 
 =head2 Delivering a Custom Error Page
 
 By default, Catalyst will display its own error page whenever it
 encounters an error in your application. When running under C<-Debug>
-mode, the error page is a useful screen including the error message and
-L<Data::Dump> output of the relevant parts of the C<$c> context object. 
-When not in C<-Debug>, users see a simple "Please come back later" screen.
+mode, the error page is a useful screen including the error message
+and L<Data::Dump> output of the relevant parts of the C<$c> context
+object.  When not in C<-Debug>, users see a simple "Please come back
+later" screen.
 
-To use a custom error page, use a special C<end> method to short-circuit
-the error processing. The following is an example; you might want to
-adjust it further depending on the needs of your application (for
-example, any calls to C<fillform> will probably need to go into this
-C<end> method; see L<Catalyst::Plugin::FillInForm>).
+To use a custom error page, use a special C<end> method to
+short-circuit the error processing. The following is an example; you
+might want to adjust it further depending on the needs of your
+application (for example, any calls to C<fillform> will probably need
+to go into this C<end> method; see L<Catalyst::Plugin::FillInForm>).
 
     sub end : Private {
         my ( $self, $c ) = @_;
@@ -52,47 +54,49 @@ You can manually set errors in your code to trigger this page by calling
 
 =head2 Disable statistics
 
-Just add this line to your application class if you don't want those nifty
-statistics in your debug messages.
+Just add this line to your application class if you don't want those
+nifty statistics in your debug messages.
 
     sub Catalyst::Log::info { }
 
 =head2 Enable debug status in the environment
 
 Normally you enable the debugging info by adding the C<-Debug> flag to
-your C<use Catalyst> statement. However, you can also enable it using
+your C<use Catalyst> statement . However, you can also enable it using
 environment variable, so you can (for example) get debug info without
 modifying your application scripts. Just set C<CATALYST_DEBUG> or
 C<E<lt>MYAPPE<gt>_DEBUG> to a true value.
 
 =head2 Sessions
 
-When you have your users identified, you will want to somehow remember that
-fact, to save them from having to identify themselves for every single
-page. One way to do this is to send the username and password parameters in
-every single page, but that's ugly, and won't work for static pages. 
+When you have your users identified, you will want to somehow remember
+that fact, to save them from having to identify themselves for every
+single page. One way to do this is to send the username and password
+parameters in every single page, but that's ugly, and won't work for
+static pages.
 
-Sessions are a method of saving data related to some transaction, and giving
-the whole collection a single ID. This ID is then given to the user to return
-to us on every page they visit while logged in. The usual way to do this is
-using a browser cookie.
+Sessions are a method of saving data related to some transaction, and
+giving the whole collection a single ID. This ID is then given to the
+user to return to us on every page they visit while logged in. The
+usual way to do this is using a browser cookie.
 
 Catalyst uses two types of plugins to represent sessions:
 
 =head3 State
 
-A State module is used to keep track of the state of the session between the
-users browser, and your application.  
+A State module is used to keep track of the state of the session
+between the users browser, and your application.
 
-A common example is the Cookie state module, which sends the browser a cookie
-containing the session ID. It will use default value for the cookie name and
-domain, so will "just work" when used. 
+A common example is the Cookie state module, which sends the browser a
+cookie containing the session ID. It will use default value for the
+cookie name and domain, so will "just work" when used.
 
 =head3 Store
 
-A Store module is used to hold all the data relating to your session, for
-example the users ID, or the items for their shopping cart. You can store data
-in memory (FastMmap), in a file (File) or in a database (DBI).
+A Store module is used to hold all the data relating to your session,
+for example the users ID, or the items for their shopping cart. You
+can store data in memory (FastMmap), in a file (File) or in a database
+(DBI).
 
 =head3 Authentication magic
 
@@ -103,15 +107,17 @@ retrieve the user data for you.
 =head3 Using a session
 
 Once the session modules are loaded, the session is available as C<<
-$c->session >>, and can be writen to and read from as a simple hash reference.
+$c->session >>, and can be writen to and read from as a simple hash
+reference.
 
 =head3 EXAMPLE
 
-  use Catalyst qw/
-                 Session
-                 Session::Store::FastMmap
-                 Session::State::Cookie
-                 /;
+  use parent qw/Catalyst/;
+  use Catalyst  qw/
+                         Session
+                         Session::Store::FastMmap
+                         Session::State::Cookie
+                   /;
 
 
   ## Write data into the session
@@ -155,36 +161,27 @@ You configure your application with the C<config> method in your
 application class. This can be hard-coded, or brought in from a
 separate configuration file.
 
-=head3 Using YAML
+=head3 Using Config::General
 
-YAML is a method for creating flexible and readable configuration
-files. It's a great way to keep your Catalyst application configuration
-in one easy-to-understand location.
+L<Config::General|Config::General> is a method for creating flexible
+and readable configuration files. It's a great way to keep your
+Catalyst application configuration in one easy-to-understand location.
 
-In your application class (e.g. C<lib/MyApp.pm>):
+Now create C<myapp.conf> in your application home:
 
-  use YAML;
-  # application setup
-  __PACKAGE__->config( YAML::LoadFile(__PACKAGE__->config->{'home'} . '/myapp.yml') );
-  __PACKAGE__->setup;
-
-Now create C<myapp.yml> in your application home:
-
-  --- #YAML:1.0
-  # DO NOT USE TABS FOR INDENTATION OR label/value SEPARATION!!!
-  name:     MyApp
+  name     MyApp
 
   # session; perldoc Catalyst::Plugin::Session::FastMmap
-  session:
-    expires:        '3600'
-    rewrite:        '0'
-    storage:        '/tmp/myapp.session'
+  <Session>
+    expires 3600
+    rewrite 0
+    storage /tmp/myapp.session
+  </Session>
 
   # emails; perldoc Catalyst::Plugin::Email
   # this passes options as an array :(
-  email:
-    - SMTP
-    - localhost
+  Mail SMTP
+  Mail localhost
 
 This is equivalent to:
 
@@ -203,7 +200,7 @@ This is equivalent to:
   # configure email sending
   __PACKAGE__->config->{email} = [qw/SMTP localhost/];
 
-See also L<YAML>.
+See also L<Config::General|Config::General>.
 
 =head1 Skipping your VCS's directories
 
@@ -270,12 +267,12 @@ in the previous example.
 The L<Catalyst::Plugin::Authorization::Roles> plugin is required when
 implementing roles:
 
+ use parent qw/Catalyst/;
  use Catalyst qw/
-    Authentication
-    Authentication::Credential::Password
-    Authentication::Store::Htpasswd
-    Authorization::Roles
-  /;
+     Authentication
+     Authentication::Credential::Password
+     Authentication::Store::Htpasswd
+     Authorization::Roles/;
 
 Roles are implemented automatically when using
 L<Catalyst::Authentication::Store::Htpasswd>:
@@ -310,8 +307,8 @@ To restrict access to any action, you can use the C<check_user_roles> method:
      # do something restricted here
   }
 
-You can also use the C<assert_user_roles> method. This just gives an error if
-the current user does not have one of the required roles:
+You can also use the C<assert_user_roles> method. This just gives an
+error if the current user does not have one of the required roles:
 
   sub also_restricted : Global {
     my ( $self, $c ) = @_;
@@ -327,27 +324,29 @@ This is done in several steps:
 =item Verification
 
 Getting the user to identify themselves, by giving you some piece of
-information known only to you and the user. Then you can assume that the user
-is who they say they are. This is called B<credential verification>.
+information known only to you and the user. Then you can assume that
+the user is who they say they are. This is called B<credential
+verification>.
 
 =item Authorization
 
-Making sure the user only accesses functions you want them to access. This is
-done by checking the verified users data against your internal list of groups,
-or allowed persons for the current page.
+Making sure the user only accesses functions you want them to
+access. This is done by checking the verified users data against your
+internal list of groups, or allowed persons for the current page.
 
 =back
 
 =head3 Modules
 
-The Catalyst Authentication system is made up of many interacting modules, to
-give you the most flexibility possible.
+The Catalyst Authentication system is made up of many interacting
+modules, to give you the most flexibility possible.
 
 =head4 Credential verifiers
 
-A Credential module tables the user input, and passes it to a Store, or some
-other system, for verification. Typically, a user object is created by either
-this module or the Store and made accessible by a C<< $c->user >> call.
+A Credential module tables the user input, and passes it to a Store,
+or some other system, for verification. Typically, a user object is
+created by either this module or the Store and made accessible by a
+C<< $c->user >> call.
 
 Examples:
 
@@ -357,9 +356,9 @@ Examples:
 
 =head3 Storage backends
 
-A Storage backend contains the actual data representing the users. It is
-queried by the credential verifiers. Updating the store is not done within
-this system, you will need to do it yourself.
+A Storage backend contains the actual data representing the users. It
+is queried by the credential verifiers. Updating the store is not done
+within this system, you will need to do it yourself.
 
 Examples:
 
@@ -368,8 +367,8 @@ Examples:
 
 =head3 User objects
 
-A User object is created by either the storage backend or the credential
-verifier, and filled with the retrieved user information.
+A User object is created by either the storage backend or the
+credential verifier, and filled with the retrieved user information.
 
 Examples:
 
@@ -377,30 +376,32 @@ Examples:
 
 =head3 ACL authorization
 
-ACL stands for Access Control List. The ACL plugin allows you to regulate
-access on a path by path basis, by listing which users, or roles, have access
-to which paths.
+ACL stands for Access Control List. The ACL plugin allows you to
+regulate access on a path by path basis, by listing which users, or
+roles, have access to which paths.
 
 =head3 Roles authorization
 
-Authorization by roles is for assigning users to groups, which can then be
-assigned to ACLs, or just checked when needed.
+Authorization by roles is for assigning users to groups, which can
+then be assigned to ACLs, or just checked when needed.
 
 =head3 Logging in
 
 When you have chosen your modules, all you need to do is call the C<<
 $c->login >> method. If called with no parameters, it will try to find
-suitable parameters, such as B<username> and B<password>, or you can pass it
-these values.
+suitable parameters, such as B<username> and B<password>, or you can
+pass it these values.
 
 =head3 Checking roles
 
-Role checking is done by using the C<< $c->check_user_roles >> method, this will
-check using the currently logged in user (via C<< $c->user >>). You pass it
-the name of a role to check, and it returns true if the user is a member.
+Role checking is done by using the C<< $c->check_user_roles >> method,
+this will check using the currently logged in user (via C<< $c->user
+>>). You pass it the name of a role to check, and it returns true if
+the user is a member.
 
 =head3 EXAMPLE
 
+ use parent qw/Catalyst/;
  use Catalyst qw/Authentication
                  Authentication::Credential::Password
                  Authentication::Store::Htpasswd
@@ -436,17 +437,17 @@ the name of a role to check, and it returns true if the user is a member.
 
 =head3 Using authentication in a testing environment
 
-Ideally, to write tests for authentication/authorization code one would first
-set up a test database with known data, then use
-L<Test::WWW::Mechanize::Catalyst> to simulate a user logging in. Unfortunately
-the former can be rather awkward, which is why it's a good thing that the
-authentication framework is so flexible.
+Ideally, to write tests for authentication/authorization code one
+would first set up a test database with known data, then use
+L<Test::WWW::Mechanize::Catalyst> to simulate a user logging
+in. Unfortunately the former can be rather awkward, which is why it's
+a good thing that the authentication framework is so flexible.
 
-Instead of using a test database, one can simply change the authentication
-store to something a bit easier to deal with in a testing
-environment. Additionally, this has the advantage of not modifying one's
-database, which can be problematic if one forgets to use the testing instead of
-production database.
+Instead of using a test database, one can simply change the
+authentication store to something a bit easier to deal with in a
+testing environment. Additionally, this has the advantage of not
+modifying one's database, which can be problematic if one forgets to
+use the testing instead of production database.
 
 e.g.,
 
@@ -470,16 +471,17 @@ L<http://search.cpan.org/perldoc?Catalyst::Plugin::Authentication> has a longer
 
 =head3 Introduction
 
-Authorization is the step that comes after authentication. Authentication
-establishes that the user agent is really representing the user we think it's
-representing, and then authorization determines what this user is allowed to
-do.
+Authorization is the step that comes after
+authentication. Authentication establishes that the user agent is
+really representing the user we think it's representing, and then
+authorization determines what this user is allowed to do.
 
 =head3 Role Based Access Control
 
-Under role based access control each user is allowed to perform any number of
-roles. For example, at a zoo no one but specially trained personnel can enter
-the moose cage (Mynd you, møøse bites kan be pretty nasti!). For example: 
+Under role based access control each user is allowed to perform any
+number of roles. For example, at a zoo no one but specially trained
+personnel can enter the moose cage (Mynd you, møøse bites kan be
+pretty nasti!). For example:
 
     package Zoo::Controller::MooseCage;
 
@@ -489,17 +491,18 @@ the moose cage (Mynd you, møøse bites kan be pretty nasti!). For example:
         $c->model( "Moose" )->eat( $c->req->param("food") );
     }
 
-With this action, anyone can just come into the moose cage and feed the moose,
-which is a very dangerous thing. We need to restrict this action, so that only
-a qualified moose feeder can perform that action.
+With this action, anyone can just come into the moose cage and feed
+the moose, which is a very dangerous thing. We need to restrict this
+action, so that only a qualified moose feeder can perform that action.
 
-The Authorization::Roles plugin let's us perform role based access control
-checks. Let's load it:
+The Authorization::Roles plugin let's us perform role based access
+control checks. Let's load it:
 
+    use parent qw/Catalyst/;
     use Catalyst qw/
-        Authentication # yadda yadda
-        Authorization::Roles
-    /;
+                    Authentication # yadda yadda
+                    Authorization::Roles
+                  /;
 
 And now our action should look like this:
 
@@ -513,11 +516,11 @@ And now our action should look like this:
         }
     }
 
-This checks C<< $c->user >>, and only if the user has B<all> the roles in the
-list, a true value is returned.
+This checks C<< $c->user >>, and only if the user has B<all> the roles
+in the list, a true value is returned.
 
-C<check_roles> has a sister method, C<assert_roles>, which throws an exception
-if any roles are missing.
+C<check_roles> has a sister method, C<assert_roles>, which throws an
+exception if any roles are missing.
 
 Some roles that might actually make sense in, say, a forum application:
 
@@ -533,62 +536,65 @@ moderator
 
 =back
 
-each with a distinct task (system administration versus content administration).
+each with a distinct task (system administration versus content
+administration).
 
 =head3 Access Control Lists
 
 Checking for roles all the time can be tedious and error prone.
 
-The Authorization::ACL plugin let's us declare where we'd like checks to be
-done automatically for us.
+The Authorization::ACL plugin let's us declare where we'd like checks
+to be done automatically for us.
 
 For example, we may want to completely block out anyone who isn't a
 C<moose_feeder> from the entire C<MooseCage> controller:
 
     Zoo->deny_access_unless( "/moose_cage", [qw/moose_feeder/] );
 
-The role list behaves in the same way as C<check_roles>. However, the ACL
-plugin isn't limited to just interacting with the Roles plugin. We can use a
-code reference instead. For example, to allow either moose trainers or moose
-feeders into the moose cage, we can create a more complex check:
+The role list behaves in the same way as C<check_roles>. However, the
+ACL plugin isn't limited to just interacting with the Roles plugin. We
+can use a code reference instead. For example, to allow either moose
+trainers or moose feeders into the moose cage, we can create a more
+complex check:
 
     Zoo->deny_access_unless( "/moose_cage", sub {
         my $c = shift;
         $c->check_roles( "moose_trainer" ) || $c->check_roles( "moose_feeder" );
     });
 
-The more specific a role, the earlier it will be checked. Let's say moose
-feeders are now restricted to only the C<feed_moose> action, while moose
-trainers get access everywhere:
+The more specific a role, the earlier it will be checked. Let's say
+moose feeders are now restricted to only the C<feed_moose> action,
+while moose trainers get access everywhere:
 
     Zoo->deny_access_unless( "/moose_cage", [qw/moose_trainer/] );
     Zoo->allow_access_if( "/moose_cage/feed_moose", [qw/moose_feeder/]);
 
-When the C<feed_moose> action is accessed the second check will be made. If the
-user is a C<moose_feeder>, then access will be immediately granted. Otherwise,
-the next rule in line will be tested - the one checking for a C<moose_trainer>.
-If this rule is not satisfied, access will be immediately denied.
+When the C<feed_moose> action is accessed the second check will be
+made. If the user is a C<moose_feeder>, then access will be
+immediately granted. Otherwise, the next rule in line will be tested -
+the one checking for a C<moose_trainer>.  If this rule is not
+satisfied, access will be immediately denied.
 
-Rules applied to the same path will be checked in the order they were added.
+Rules applied to the same path will be checked in the order they were
+added.
 
-Lastly, handling access denial events is done by creating an C<access_denied>
-private action:
+Lastly, handling access denial events is done by creating an
+C<access_denied> private action:
 
     sub access_denied : Private {
         my ( $self, $c, $action ) = @_;
-
-        
     }
 
-This action works much like auto, in that it is inherited across namespaces
-(not like object oriented code). This means that the C<access_denied> action
-which is B<nearest> to the action which was blocked will be triggered.
+This action works much like auto, in that it is inherited across
+namespaces (not like object oriented code). This means that the
+C<access_denied> action which is B<nearest> to the action which was
+blocked will be triggered.
 
-If this action does not exist, an error will be thrown, which you can clean up
-in your C<end> private action instead.
+If this action does not exist, an error will be thrown, which you can
+clean up in your C<end> private action instead.
 
-Also, it's important to note that if you restrict access to "/" then C<end>,
-C<default>, etc will also be restricted.
+Also, it's important to note that if you restrict access to "/" then
+C<end>, C<default>, etc will also be restricted.
 
    MyApp->acl_allow_root_internals;
 
@@ -603,10 +609,10 @@ are just the start.
 
 =head2 Using existing DBIC (etc.) classes with Catalyst
 
-Many people have existing Model classes that they would like to use with
-Catalyst (or, conversely, they want to write Catalyst models that can be
-used outside of Catalyst, e.g.  in a cron job). It's trivial to write a
-simple component in Catalyst that slurps in an outside Model:
+Many people have existing Model classes that they would like to use
+with Catalyst (or, conversely, they want to write Catalyst models that
+can be used outside of Catalyst, e.g.  in a cron job). It's trivial to
+write a simple component in Catalyst that slurps in an outside Model:
 
     package MyApp::Model::DB;
     use base qw/Catalyst::Model::DBIC::Schema/;
@@ -623,6 +629,38 @@ Cat app as C<MyApp::Model::DB>.
 
 See L<Catalyst::Model::DBIC::Schema>.
 
+=head2 Create accessors to preload static data once per server instance
+
+When you have data that you want to load just once from the model at
+server load instead of for each request, use mk_group_accessors to
+create accessors and tie them to resultsets in your package that
+inherits from DBIx::Class::Schema
+
+    package My::Schema;
+    use base qw/DBIx::Class::Schema/;
+    __PACKAGE__->register_class('RESULTSOURCEMONIKER',
+                                'My::Schema::RESULTSOURCE');
+    __PACKAGE__->mk_group_accessors('simple' =>
+                                qw(ACCESSORNAME1 ACCESSORNAME2 ACCESSORNAMEn));
+
+    sub connection {
+        my ($self, @rest) = @_;
+        $self->next::method(@rest);
+        # $self is now a live My::Schema object, complete with DB connection 
+
+        $self->ACCESSORNAME1([ $self->resultset('RESULTSOURCEMONIKER')->all ]);
+        $self->ACCESSORNAME2([ $self->resultset('RESULTSOURCEMONIKER')->search({ COLUMN => { '<' => '30' } })->all ]);
+        $self->ACCESSORNAMEn([ $self->resultset('RESULTSOURCEMONIKER')->find(1) ]);
+    }
+
+    1;
+
+and now in the controller, you can now access any of these without a
+per-request fetch:
+
+    $c->stash->{something} = $c->model('My::Schema')->schema->ACCESSORNAMEn;
+
+
 =head2 XMLRPC
 
 Unlike SOAP, XMLRPC is a very simple (and imo elegant) web-services
@@ -687,7 +725,7 @@ later) and SOAP::Lite (for XMLRPCsh.pl).
 5. Add a XMLRPC redispatch method and an add method with Remote
 attribute to lib/MyApp/Controller/API.pm
 
-    sub default : Private {
+    sub default :Path {
         my ( $self, $c ) = @_;
         $c->xmlrpc;
     }
@@ -912,15 +950,35 @@ In your template, you can use the following:
 
     <a href="[% c.uri_for('/login') %]">Login Here</a>
 
-Although the parameter starts with a forward slash, this is relative to the application root, not the webserver root. This is important to remember. So, if your application is installed at http://www.domain.com/Calendar, then the link would be http://www.mydomain.com/Calendar/Login. If you move your application to a different domain or path, then that link will still be correct.
+Although the parameter starts with a forward slash, this is relative
+to the application root, not the webserver root. This is important to
+remember. So, if your application is installed at
+http://www.domain.com/Calendar, then the link would be
+http://www.mydomain.com/Calendar/Login. If you move your application
+to a different domain or path, then that link will still be correct.
 
 Likewise,
 
     <a href="[% c.uri_for('2005','10', '24') %]">October, 24 2005</a>
 
-The first parameter does NOT have a forward slash, and so it will be relative to the current namespace. If the application is installed at http://www.domain.com/Calendar. and if the template is called from MyApp::Controller::Display, then the link would become http://www.domain.com/Calendar/Display/2005/10/24.
+The first parameter does NOT have a forward slash, and so it will be
+relative to the current namespace. If the application is installed at
+http://www.domain.com/Calendar. and if the template is called from
+MyApp::Controller::Display, then the link would become
+http://www.domain.com/Calendar/Display/2005/10/24.
 
-Once again, this allows you to move your application around without having to worry about broken links. But there's something else, as well. Since the links are generated by uri_for, you can use the same template file by several different controllers, and each controller will get the links that its supposed to. Since we believe in Don't Repeat Yourself, this is particularly helpful if you have common elements in your site that you want to keep in one file.
+If you want to link to a parent uri of your current namespace you can
+prefix the arguments with multiple '../':
+
+    <a href="[% c.uri_for('../../view', stashed_object.id) %]">User view</a>
+
+Once again, this allows you to move your application around without
+having to worry about broken links. But there's something else, as
+well. Since the links are generated by uri_for, you can use the same
+template file by several different controllers, and each controller
+will get the links that its supposed to. Since we believe in Don't
+Repeat Yourself, this is particularly helpful if you have common
+elements in your site that you want to keep in one file.
 
 Further Reading:
 
@@ -1093,12 +1151,13 @@ you can set it up like this:
 
 =head3 Introduction
 
-A Catalyst application is driven by one or more Controller modules. There are
-a number of ways that Catalyst can decide which of the methods in your
-controller modules it should call. Controller methods are also called actions,
-because they determine how your catalyst application should (re-)act to any
-given URL. When the application is started up, catalyst looks at all your
-actions, and decides which URLs they map to.
+A Catalyst application is driven by one or more Controller
+modules. There are a number of ways that Catalyst can decide which of
+the methods in your controller modules it should call. Controller
+methods are also called actions, because they determine how your
+catalyst application should (re-)act to any given URL. When the
+application is started up, catalyst looks at all your actions, and
+decides which URLs they map to.
 
 =head3 Type attributes
 
@@ -1118,8 +1177,9 @@ server default).
 =item Path
 
 A Path attribute also takes an argument, this can be either a relative
-or an absolute path. A relative path will be relative to the controller
-namespace, an absolute path will represent an exact matching URL.
+or an absolute path. A relative path will be relative to the
+controller namespace, an absolute path will represent an exact
+matching URL.
 
  sub my_handles : Path('handles') { .. }
 
@@ -1137,9 +1197,9 @@ becomes
 
 =item Local
 
-When using a Local attribute, no parameters are needed, instead, the name of
-the action is matched in the URL. The namespaces created by the name of the
-controller package is always part of the URL.
+When using a Local attribute, no parameters are needed, instead, the
+name of the action is matched in the URL. The namespaces created by
+the name of the controller package is always part of the URL.
 
  sub my_handles : Local { .. }
 
@@ -1149,8 +1209,8 @@ becomes
 
 =item Global
 
-A Global attribute is similar to a Local attribute, except that the namespace
-of the controller is ignored, and matching starts at root.
+A Global attribute is similar to a Local attribute, except that the
+namespace of the controller is ignored, and matching starts at root.
 
  sub my_handles : Global { .. }
 
@@ -1160,9 +1220,9 @@ becomes
 
 =item Regex
 
-By now you should have figured that a Regex attribute is just what it sounds
-like. This one takes a regular expression, and matches starting from
-root. These differ from the rest as they can match multiple URLs.
+By now you should have figured that a Regex attribute is just what it
+sounds like. This one takes a regular expression, and matches starting
+from root. These differ from the rest as they can match multiple URLs.
 
  sub my_handles : Regex('^handles') { .. }
 
@@ -1195,39 +1255,40 @@ etc.
 
 =item Private
 
-Last but not least, there is the Private attribute, which allows you to create
-your own internal actions, which can be forwarded to, but won't be matched as
-URLs.
+Last but not least, there is the Private attribute, which allows you
+to create your own internal actions, which can be forwarded to, but
+won't be matched as URLs.
 
  sub my_handles : Private { .. }
 
 becomes nothing at all..
 
-Catalyst also predefines some special Private actions, which you can override,
-these are:
+Catalyst also predefines some special Private actions, which you can
+override, these are:
 
 =over 4
 
 =item default
 
-The default action will be called, if no other matching action is found. If
-you don't have one of these in your namespace, or any sub part of your
-namespace, you'll get an error page instead. If you want to find out where it
-was the user was trying to go, you can look in the request object using 
-C<< $c->req->path >>.
+The default action will be called, if no other matching action is
+found. If you don't have one of these in your namespace, or any sub
+part of your namespace, you'll get an error page instead. If you want
+to find out where it was the user was trying to go, you can look in
+the request object using C<< $c->req->path >>.
 
- sub default : Private { .. }
+ sub default :Path { .. }
 
-works for all unknown URLs, in this controller namespace, or every one if put
-directly into MyApp.pm.
+works for all unknown URLs, in this controller namespace, or every one
+if put directly into MyApp.pm.
 
 =item index 
 
-The index action is called when someone tries to visit the exact namespace of
-your controller. If index, default and matching Path actions are defined, then
-index will be used instead of default and Path.
+The index action is called when someone tries to visit the exact
+namespace of your controller. If index, default and matching Path
+actions are defined, then index will be used instead of default and
+Path.
 
- sub index : Private { .. }
+ sub index :Path :Args(0) { .. }
 
 becomes
 
@@ -1235,10 +1296,11 @@ becomes
 
 =item begin
 
-The begin action is called at the beginning of every request involving this
-namespace directly, before other matching actions are called. It can be used
-to set up variables/data for this particular part of your app. A single begin
-action is called, its always the one most relevant to the current namespace.
+The begin action is called at the beginning of every request involving
+this namespace directly, before other matching actions are called. It
+can be used to set up variables/data for this particular part of your
+app. A single begin action is called, its always the one most relevant
+to the current namespace.
 
  sub begin : Private { .. }
 
@@ -1250,10 +1312,10 @@ is visited.
 
 =item end
 
-Like begin, this action is always called for the namespace it is in, after
-every other action has finished. It is commonly used to forward processing to
-the View component. A single end action is called, its always the one most
-relevant to the current namespace. 
+Like begin, this action is always called for the namespace it is in,
+after every other action has finished. It is commonly used to forward
+processing to the View component. A single end action is called, its
+always the one most relevant to the current namespace.
 
 
  sub end : Private { .. }
@@ -1266,10 +1328,10 @@ is visited.
 
 =item auto
 
-Lastly, the auto action is magic in that B<every> auto action in
-the chain of paths up to and including the ending namespace, will be
-called. (In contrast, only one of the begin/end/default actions will be
-called, the relevant one).
+Lastly, the auto action is magic in that B<every> auto action in the
+chain of paths up to and including the ending namespace, will be
+called. (In contrast, only one of the begin/end/default actions will
+be called, the relevant one).
 
  package MyApp.pm;
  sub auto : Private { .. }
@@ -1288,9 +1350,9 @@ will both be called when visiting
 
 =head3 A word of warning
 
-Due to possible namespace conflicts with Plugins, it is advised to only put the
-pre-defined Private actions in your main MyApp.pm file, all others should go
-in a Controller module.
+Due to possible namespace conflicts with Plugins, it is advised to
+only put the pre-defined Private actions in your main MyApp.pm file,
+all others should go in a Controller module.
 
 =head3 More Information
 
@@ -1704,7 +1766,7 @@ The development server is a mini web server written in perl.  If you
 expect a low number of hits or you don't need mod_perl/FastCGI speed,
 you could use the development server as the application server with a
 lightweight proxy web server at the front.  However, consider using
-L<Catalyst::Engine::HTTP::POE> for this kind of deployment instead, since
+L<Catalyst::Engine::HTTP::Prefork> for this kind of deployment instead, since
 it can better handle multiple concurrent requests without forking, or can
 prefork a set number of servers for improved performance.
 
@@ -1749,9 +1811,18 @@ Make sure mod_proxy is enabled and add:
         Order deny,allow
         Allow from all
     </Proxy>
+
+    # Need to specifically stop these paths from being passed to proxy
+    ProxyPass /static !
+    ProxyPass /favicon.ico !
+
     ProxyPass / http://localhost:8080/
     ProxyPassReverse / http://localhost:8080/
 
+    # This is optional if you'd like to show a custom error page 
+    # if the proxy is not available
+    ErrorDocument 502 /static/error_pages/http502.html
+
 You can wrap the above within a VirtualHost container if you want
 different apps served on the same host.
 
@@ -2034,10 +2105,10 @@ There are three wrapper plugins around common CPAN cache modules:
 Cache::FastMmap, Cache::FileCache, and Cache::Memcached.  These can be
 used to cache the result of slow operations.
 
-This very page you're viewing makes use of the FileCache plugin to cache the
+The Catalyst Advent Calendar uses the FileCache plugin to cache the
 rendered XHTML version of the source POD document.  This is an ideal
-application for a cache because the source document changes infrequently but
-may be viewed many times.
+application for a cache because the source document changes
+infrequently but may be viewed many times.
 
     use Catalyst qw/Cache::FileCache/;