X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FCookbook.pod;h=58e9d0a29b2969f866c6561f398d57af63fe7e65;hp=9521beb06c09c05d7488dde125d7bc290cbbf088;hb=080bb6202ae1dc9a786bb32afcb391f542c2f0fc;hpb=bf6900ba7094f316737b7ed55ec44dea547f39c0 diff --git a/lib/Catalyst/Manual/Cookbook.pod b/lib/Catalyst/Manual/Cookbook.pod index 9521beb..58e9d0a 100644 --- a/lib/Catalyst/Manual/Cookbook.pod +++ b/lib/Catalyst/Manual/Cookbook.pod @@ -1,3 +1,5 @@ +=encoding utf8 + =head1 NAME Catalyst::Manual::Cookbook - Cooking with Catalyst @@ -68,7 +70,7 @@ Normally you enable the debugging info by adding the C<-Debug> flag to your C 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 or -CMYAPPE_DEBUG> to a true value. +C<< _DEBUG >> to a true value. =head2 Sessions @@ -110,7 +112,7 @@ 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 +$c->session >>, and can be written to and read from as a simple hash reference. =head3 EXAMPLE @@ -154,17 +156,17 @@ reference. =head3 More information -L +L -L +L -L +L -L +L -L +L -L +L =head2 Configure your application @@ -178,7 +180,7 @@ L 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. -Now create C in your application home: +Now create F in your application home: name MyApp @@ -199,17 +201,25 @@ This is equivalent to: # configure base package __PACKAGE__->config( name => MyApp ); # configure authentication - __PACKAGE__->config->{authentication} = { - user_class => 'MyApp::Model::MyDB::Customer', - ... - }; + __PACKAGE__->config( + 'Plugin::Authentication' => { + user_class => 'MyApp::Model::MyDB::Customer', + ... + }, + _; # configure sessions - __PACKAGE__->config->{session} = { - expires => 3600, - ... - }; + __PACKAGE__->config( + session => { + expires => 3600, + ... + }, + ); # configure email sending - __PACKAGE__->config->{email} = [qw/SMTP localhost/]; + __PACKAGE__->config( email => [qw/SMTP localhost/] ); + +L explains precedence of multiple sources for configuration +values, how to access the values in your components, and many 'base' +config variables used internally. See also L. @@ -572,7 +582,7 @@ root of your app (but not in any other controller). =head1 Models -Models are where application data belongs. Catalyst is exteremely +Models are where application data belongs. Catalyst is extremely flexible with the kind of models that it can use. The recipes here are just the start. @@ -589,7 +599,7 @@ write a simple component in Catalyst that slurps in an outside Model: __PACKAGE__->config( schema_class => 'Some::DBIC::Schema', - connect_info => ['dbi:SQLite:foo.db', '', '', {AutoCommit=>1}]; + connect_info => ['dbi:SQLite:foo.db', '', '', {AutoCommit=>1}], ); 1; @@ -811,17 +821,17 @@ This time, the helper sets several options for us in the generated View. =over -=item +=item * INCLUDE_PATH defines the directories that Template Toolkit should search for the template files. -=item +=item * PRE_PROCESS is used to process configuration options which are common to every template file. -=item +=item * WRAPPER is a file which is processed with each template, usually used to easily provide a common header and footer for every page. @@ -841,12 +851,12 @@ organization provided makes it much easier to standardize pages and make changes when they are (inevitably) needed. The template files that you will create for your application will go -into root/src, and you don't need to worry about putting the the +into root/src, and you don't need to worry about putting the or sections; just put in the content. The WRAPPER will the rest of the page around your template for you. -=head3 $c->stash +=head3 C<< $c->stash >> Of course, having the template system include the header and footer for you isn't all that we want our templates to do. We need to be able to @@ -901,7 +911,7 @@ This is the most basic usage, but Template Toolkit is quite powerful, and allows you to truly keep your presentation logic separate from the rest of your application. -=head3 $c->uri_for() +=head3 C<< $c->uri_for() >> One of my favorite things about Catalyst is the ability to move an application around without having to worry that everything is going to @@ -912,7 +922,7 @@ to "/Calendar", "/Calendar/2005", "/Calendar/2005/10", etc. If you move the application to be at http://www.mydomain.com/Tools/Calendar, then all of those links will suddenly break. -That's where $c->uri_for() comes in. This function will merge its +That's where C<< $c->uri_for() >> comes in. This function will merge its parameters with either the base location for the app, or its current namespace. Let's take a look at a couple of examples. @@ -934,7 +944,7 @@ Likewise, 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 +C, then the link would become http://www.domain.com/Calendar/Display/2005/10/24. If you want to link to a parent uri of your current namespace you can @@ -952,56 +962,22 @@ elements in your site that you want to keep in one file. Further Reading: -L +L -L +L -L +L