Gentlemen, a call to arms!

Jonathan Rockway jon at jrock.us
Mon Oct 16 18:34:09 BST 2006


> I'm in the process of writing one myself. I'm using CGI::Application
> now, because I tried plugging authentication plugins into Catalyst and
> the code barfed horribly. And then, of course, I found myself stuck
> because all the "helper" applications had written a pile of code I had
> no clue about and I just couldn't get debugged. So I gave up.

I agree that documentation isn't as good as it could be.  That's why I'm
writing a book.

For now, I do recommend the tutorial; I found it to be quite helpful:

http://search.cpan.org/~jrockway/Task-Catalyst-Tutorial-0.02/lib/Catalyst/Manual/Tutorial.pod

(It's in my CPAN directory, but I just maintain the CPAN version.  The
tutorial was written by Kennedy Clark.)

> (As I recall one of the entries in the Pragmatic Programmers book was
> along the lines of "beware of wizards", and this seemed to fit that one
> well.)

Really, the helpers aren't wizards.  They're typing savers.  Every
catalyst app has the same sort of layout, so the helpers set that up for
you:

catalyst.pl MyApp creates:

myapp.yml # default config file
root/     # where your templates go
MyApp.pm  # your application; setup plugins and config here
MyApp/Controller/Root.pm # your "main" controller for /
  __PACKAGE__->config->{namespace} = ''; # so that actions are in /, not
                                         # /root
  sub default : Private { } # default action, 404 or maybe "it works!"
MyApp/Model/* # none by default
MyApp/View/*  # none by default

After you get situated with that, you can add a TT view:
$ myapp_create.pl view TT TT

Which creates:
MyApp/View/TT.pm # subclass of Catalyst::View::TT, well-documented

And you'll want a database:
$ myapp_create.pl model MyModel DBIC::Schema MyApp::Schema create=static
dbi:SQLite:/tmp/timeline.db # or any DBI connect line

Which gives you:
MyApp/Model/MyModel.pm # loads your schema
MyApp/Schema/* # create your database schema in here, SQL::Translator
               # will make the actual tables for you
example:
MyApp/Schema/Table.pm # represents "table" in the database (could be a
                      # stored procedure or view, though)

Now you have $c->model('MyModel::Table') to query against that "Table"
in your database, and you have a view to make the data look nice.

Anyway, no magic, just removal of tedium.  You can create the Schema
from an existing database, as well, which saves you even more typing!

If you (or anyone else) has questions, please ask on #catalyst or the
mailing lists -- we're happy to answer.  It's much easier for us to
improve the docs (or the framework itself) if we know what the problems
are.  (Case in point:  A few days ago someone asked how to set
environment variables from the Catalyst config file.  In about an hour,
I wrote and CPAN'd a module to do just that.  I never thought about
needing that functionality, but when someone else brought it up, I
implemented it.  Now I'm a user too! :)

The point is, please talk to us!  Thanks!

Regards,
Jonathan Rockway

(yes, you can have one line catalyst apps)
-- 
package JAPH;use Catalyst qw/-Debug/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //,
";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;


More information about the london.pm mailing list