Splitting a Catalyst App and recombining it with Plack::Builder

I had a big Catalyst App serving HTML.

Some time later a RESTful interface was needed so I added RESTful controllers using Catalyst::Controller::REST

But that broke Plack::Middleware::CSRFBlock, because the REST calls don't request a form and thus cannot add the secure token to POST requests.

Thinking about a solution it dawned on my that having a single App serving HTML and RESTful requests is probably a bad design choice.

Thankfully most of my business logic is in my DBIx::Class schema so splitting up one Catalyst App into two Catalyst Apps under the same nam…

Asynchronous Task Distribution with AnyEvent and ZeroMQ

Some months ago i wrote how to (ab)use your database as a messagequeue in order to distribute tasks among worker-processes.

"From your code, it also looks like having more than one demon will put you at risk of processing the same jobs more than once." (Jerome Eteve)

"Abuse" is the right word. The moment you hit more than three concurrent jobs, you will see a nasty slowdown ..." (rob.kinyon)

The comments made pretty clear that this was not a go…

bulk inserting tens of thousands of rows with DBIx::Class

For some crazy reason my $project had a denormalized database layout. I had a table 'job' with a column 'data' which had a serialized ArrayRef of HashRefs as value.

But performance turned out to be really bad, I did not take any premature measu…

Relationships with optional foreign key values (DBIx::Class)

This entry demonstrates how to implement a relationship with optional foreign key values using DBIx::Class.

Imagine two related tables 'human' and 'cat': A cat belongs to a human but when the human dies the cat can continue to roam freely.

package MyApp::Schema::Result::Human;
use strict;
use warnings;
use base 'DBIx::Class';
__PACKAGE__->load_components(qw/ Core /);
__PACKAGE__->table('human');
__PACKAGE__->add_columns(
    id => {
        data_type         => 'integer',
        is_auto_increment => 1,
        is_numeric        => 1,
    },
);
__PA…

parameterizable packages with Package::Variant

Yesterday I tried to port a Moose App to Moo but got stuck when I found out it is using MooseX::Role::Parameterizable, a module not available in Moo. A quick visit in channel #moose on perl.irc.org later and I was told to give Package::Variant a try.

Few lines of conversation/debugging later and here is my parameterizable HTML::FormHandler role. Package::Variant is an extremly promising module to me that is really helpful when refactoring your code.

declare the HFH role

package MyApp::Role::Form::Step:…