A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label catalyst. Show all posts
Showing posts with label catalyst. Show all posts

Testing Catalyst

Notes:

Catalyst::Test - you get a context object back

Test::WWW::Mechanize::Catalyst - you don't have to run a separate server

Catalyst controller basics

Create a controller module:

    myapp_create.pl Controller Foo

created "......../lib/Controller/Foo.pm"
created "......../t/controller_Foo.t"

Inside Foo.pm:

sub index :Path :Args(0) {
    my ( $self, $c ) = @_;
    $c->response->body('Matched XXXX::Controller::Foo in Foo.');
}

sub root :Chained('/') :PathPrefix :CaptureArgs(0) {
    # common stuff for this controller
}
                        
sub bar :Chained('root') :PathPart('bar') :Args(0) {
    my ( $self, $c ) = @_;
    # something
}

How to use Catalyst to automatically create Perl DBIx::Class modules

UNTESTED:

1. install Catalyst

2. pretend like you're going to create a catalyst app

catalyst.pl MyFakeApp

3.

cd MyFakeApp
./script/myfakeapp_create.pl model MyModelName DBIC::Schema \
MyApp::SchemaClass create=static dbi:mysql:... user password


http://search.cpan.org/~rkitover/Catalyst-Model-DBIC-Schema-0.29/lib/Catalys
t/Helper/Model/DBIC/Schema.pm



one I did earlier

perl ./script/tagindexer_create.pl model RequestDB DBIC::Schema
TagIndexer::Schema create=static
'dbi:mysql:database=request;host=[ip address];port=3306' tagindexer
tagindexer