I've used Perl for about ten years, and have experience with all of the "pre-Catalyst" frameworks and helpers (from CGI.pm to CGI::Application to dalliances with writing my own and trying Jifty). I've also used Rails and read several books on it (most of which are disappointments).
Unfortunately, I found this guide a disappointment as well. Most of the book seems to be structured around a few "examples," the largest of which is a translation app from English into "Lolcat." The problem with such an app as an example is that it could readily be done in a dead-simple, several-line CGI script (hell, even a one-liner could probably do it), so it requires a certain suspension of disbelief that one should be using stashes, chained dispatch methods, templates, and the like. Why not a normal CRUD type app as an example? Boring, yes, but to-the-point and more likely to be illustrative of the tools and their best applications.
The conversational "flow" of the book is distracting, as well. I understand that a more tabular or outlined form for making specific information easier to find could render it hard to read "straight through" as a book. But the sheer volume of information, and diversity of scenarios, make it unlikely that anyone will read it straight through and make equal use of all parts. Far better to organize the content more rigorously by function -- for example, the best and best-structured chapter by far is the chapter on dispatch (it gets to borrow for its prose structure from the flow chart on page 168. Less in-depth meanderings into such adjuncts as DBIx::Class and Moose, but more on how (if at all) such outside modules must interface / play nice with the Catalyst core. A chapter on errors. A chapter on logging. A chapter on templating.
The index is a mess and lazily put together. Under "log", only one entry: "Logging, in Catalyst, 7." (Are you serious? who wrote that index entry? Logging, comma, IN CATALYST?!? SERIOUSLY??) For "error:" "error handling code, changing to output errors to the log, 104-105." Nothing for "exception" (fair enough, as Perl properly has none), but under Perl's equivalent, "die:" "die, using for error handling, 156." WTF? Finding these three sections shouldn't be an Easter-egg hunt. WTF would be wrong with:
error
using "die" ... 156
logging ... 104-105
see also *log*
log ... 7
errors ... 104-105
I'm rooting for Matt & co., and I'm a fan of Catalyst. But this book needs a reworking for its next edition, and it needs an editor (the typography, too, is underwhelming). It's not that the team that wrote this isn't smart enough, or that they don't know the subject well enough. It's merely that they need to structure, structure, structure, and clarify, clarify, clarify. Looking forward to second edition, guys.
Author(s): Kieren Diment, Matt Trout
Edition: 1
Publisher: Apress
Year: 2009
Language: English
Pages: 362
Prelims
......Page 1
Contents at a Glance......Page 7
Contents......Page 9
Catalyst Is CPAN......Page 17
Reinventing Perl with Perl......Page 18
The Future of Catalyst......Page 19
About the Authors......Page 21
About the Technical Reviewer......Page 23
Acknowledgments......Page 25
Beginning......Page 27
Catalyst and Perl......Page 28
Introducing the catalyst Web application Framework......Page 31
The Model/View/Controller Pattern......Page 32
URL Path Dispatch Logic......Page 36
Logging......Page 37
Deployment......Page 38
Catalyst vs. Cgi......Page 39
mod_perl......Page 42
URI Routing via External File vs. Self-Contained Controllers......Page 43
Catalyst vs. CGI::Application......Page 44
Catalyst vs. Jifty......Page 46
summary......Page 47
Choosing Hardware and Software......Page 49
Linux......Page 51
BSD......Page 52
Setting Up CPAN......Page 53
Hypertext Transfer Protocol......Page 54
Object-Oriented Programming with Moose......Page 58
Moose example: Snow White and the 57 Dwarfs......Page 62
More on Moose......Page 71
Making the Most of CPAn......Page 74
Search Strategies for CPAN......Page 75
Basic CPAN Usage......Page 77
testing cpaN Modules......Page 78
Summary......Page 82
Sample Application Overview......Page 83
Top-Level Directory......Page 84
script Directory......Page 85
t Directory......Page 86
Getting Started Writing Our Application......Page 87
Writing the Application......Page 89
A Brief Explanation of Views......Page 91
Our First Template......Page 92
A Brief Introduction to Catalyst Models......Page 95
Adding a Different View......Page 96
Testing......Page 97
Automated Testing......Page 99
Fixing the Plan......Page 101
Checking and Fixing the JSON Request......Page 102
Adding Authentication for the Web portion of Our Application......Page 104
Requiring Authentication for Web Services Requests Only......Page 105
Summary......Page 109
extending LolCatalyst-Lite......Page 111
Measure Twice, Code Once......Page 112
Extracting the Model......Page 113
Moving the Model Logic into an Application-Independent Class......Page 114
Extending the Model......Page 117
A Driver Model for Generic Translation......Page 118
Fixing Up the Makefile.PL......Page 119
Enforcing the Interface Using a Role......Page 123
Interlude: LolCatalyst::Lite::Model::SnippetStore......Page 124
Extending the application......Page 126
A Chained Controller......Page 127
Adding Templates......Page 130
Interlude: Converting the Snippets to Be Object Based......Page 131
thin Controller, smart Model......Page 132
Adding Tests for the New View Functionality......Page 135
summary......Page 138
Using the Built-in Server......Page 139
Deploying with the Built-in Server......Page 140
HTTP::Prefork Engine Behind a Front-End Proxy......Page 141
Lighttpd......Page 142
apache......Page 145
Nginx......Page 146
FastCGI Deployment......Page 147
FastCGI Deployment on Your Own Web Server......Page 148
apache......Page 149
Lighttpd......Page 151
Nginx......Page 152
Deployment on mod_perl......Page 153
Rsync......Page 155
make dist......Page 156
To make install or Not to make install, That Is the Question......Page 157
Dependency Installation......Page 158
The cpan . Command......Page 160
make installdeps......Page 161
make catalyst_par......Page 162
Summary......Page 163
Popular Database Systems......Page 165
Connecting to the Database from Catalyst......Page 166
Designing and Creating the Sample Application Database......Page 167
Creating the Catalyst Model......Page 169
The Schema File......Page 171
The Result Files......Page 172
relationships......Page 173
Components......Page 175
Deploying to a Different Database System......Page 177
Dealing with Data......Page 179
Simple CRUD......Page 180
Creating a User......Page 181
Displaying Users......Page 185
Updating Users......Page 187
Adding Roles......Page 189
Adding Roles to Users......Page 190
Removing a User......Page 193
Listing All Users and Their Roles......Page 194
Summary......Page 196
the Catalyst Dispatcher......Page 197
The Basic Dispatch Process......Page 199
Two Special Dispatch Types: begin and auto......Page 201
LocalRegex and Regex Actions......Page 205
internal Request Flow Control: $c->forward, $c->detach, $c->go, and $c->visit......Page 207
forward and detach......Page 208
visit and go......Page 210
The Chained Dispatch Type......Page 211
overriding the Public Dispatch Paths with Configuration......Page 217
Summary......Page 218
The Three Parts of Authentication......Page 219
Authentication Realms......Page 220
Persistence......Page 221
Authorization with Roles......Page 222
Catalyst::Authentication::Store::DBIx::Class......Page 223
Our Example Application: SneakyCat......Page 224
Creating and Configuring SneakyCat......Page 225
the password Credential......Page 228
the DBIx::Class Store......Page 229
A Side Trip into Application Setup......Page 230
Using Authentication......Page 233
Working with Authentication After Login......Page 237
Trying Out the Application......Page 239
Adding Finer-Grained Access Control to SneakyCat with Authorization......Page 241
Working with the Authenticated User......Page 246
Summary......Page 248
Consuming a Simple REST Service......Page 249
Setting Up OpenCalais in a Catalyst Application......Page 250
Implementing the REST Controller......Page 254
Changing the Data Type for Serialization......Page 258
Remaining Options for Web Services......Page 259
SOap......Page 260
Summary......Page 261
Base Controllers......Page 263
A Simple SerialiseStashKey View......Page 264
Adding Attributes to Controller Actions......Page 267
A More Sophisticated Example......Page 268
Adding More Than One New Attribute......Page 270
Cleaning Up Multiple Attributes with Roles......Page 271
Helper Methods in MyApp.pm......Page 272
Catalyst::Plugin::Static::Simple......Page 274
Summary......Page 275
Model/View/Controller......Page 277
Import Existing Schemas to DBIx::Class......Page 278
Use DBIx::Class::Tree and Display with JavaScript and the Template Toolkit......Page 279
Catalyst::Model::Factory and Catalyst::Model:: Factory::PerRequest......Page 284
A Way to Quickly Resolve Browser Compatibility Issues......Page 285
See also......Page 288
Dynamically Generate Graphics with Catalyst::View::GD......Page 289
Dynamically Generate Barcodes from Catalyst......Page 290
Produce Graphs with Chart::Clicker and Catalyst::View:: Graphics::Primitive......Page 292
Alternative Templating Systems......Page 294
Easy Spam Protection with Catalyst::Controller::reCAPTCHA......Page 297
See also......Page 298
Catalyst::View::Component::SubInclude......Page 299
Handle Legacy CGI Scripts in Catalyst......Page 300
Catalyst::Controller::WrapCGI......Page 301
Intelligent Use of Base Controllers......Page 302
See also......Page 304
Catalyst::View::Email::Template......Page 305
Run Parts of an Application As a Stand-Alone Script......Page 307
MojoMojo: The Catalyst Wiki......Page 308
Setting Up the Wiki......Page 309
Database Configuration......Page 310
Persistent Login and API Authentication......Page 311
authentication Keys......Page 312
Some Important Notes about persistent Login......Page 315
Multirealm and Progressive Authentication......Page 316
Deploy with a Cache......Page 319
Enforce Coding Standards with Perl::Critic and Perl::Tidy......Page 322
placing Configuration in a Constants File......Page 324
See also......Page 325
Workflow Testing with Test::WWW::Mechanize::Catalyst......Page 326
Write a Minimal Test Case to Troubleshoot......Page 327
Bash Aliases to Make Starting the Development Server Easier......Page 329
Alternative to perl -d: Devel::REPL and CatalystX::REPL......Page 330
Summary......Page 331
Reaction Overview......Page 333
Metaprogramming......Page 334
Infrastructure......Page 335
Basic UI Components......Page 336
actions......Page 337
Our Interface Model......Page 338
The View......Page 340
The Root Controller......Page 341
The LayoutSet......Page 343
Summary......Page 344
Compiling Your Own perl......Page 345
Patching Perl 5.10.0 to Work (Properly) with Catalyst......Page 346
Making Your Own CpAn Mirror with CpAn::Mini or minicpan.sh......Page 347
Browsing Your minicpan on the Web......Page 348
Index......Page 349