Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

kaare (663)

kaare
  (email not shown publicly)

Journal of kaare (663)

Thursday April 26, 2007
05:41 AM

Scream, Bitch, Scream!

I just spent 5 hours yesterday debugging, searching for a bug in a Catalyst/DBIC application. How life would be easier if DBIC would die screaming instead of just bailing out in silent mode.

Combined with Catalyst's very talkative error trace, I get tons and tons of nonsense, and no useful information. In this case I was told that the problem was that there was an earlier transaction with problems. Well doh! Not very interesting. Tell me why you die, please.

Another thing about DBIC seems to be that $schema is utterly useless after a failed txn_do. You can get a resultset, see the classname, resoultsource etc. But don't you dare! to find some data. Why? Well, I don't know.

Saturday April 21, 2007
03:03 AM

Sickness--

I was sick all week of Easter. I mean really sick with pills, pain and phever. Thatsa good boy, taking your sick time in the Holidays. Very clever!

But every day since then I've developed fever and pain during daytime, until two days ago I had the first day with no pain killers. My Goodness! What's the point? Depression is an extra added bonus, feeling power- and useless.

Well, now it's over at least, and I can start on the piles that has built themselves in the meantime :-(

Sunday April 01, 2007
11:54 AM

The Perl Review

Woohoo!!

TPR 3.2 arrived here yesterday, even without having me bother brian about it!

I know it's late compared to everybody else, but hey! Surface mail to Denmark is recognized as the slowest moving item on Earth.

I don't know how many times I've had to request him to send me a new copy because the first was lost in the mail (never any complaints), but now there's hope. The last two issues arrived

The content is not really new, though, as I couldn't help skimming the PDF version. Most important: A lot about Nordic Perl Workshop, this year's most important event! :-)

Thursday March 29, 2007
05:16 AM

DBIx::Class ResultSets

It's easy to do single-table stuff with DBIx::Class. And even more complex actions are well supported, but you risk duplicating your code if you don't watch out.

Especially if you use Catalyst, it's easy to write the same piece of code to fetch or update related tables in several controllers.

This will surely and quickly become a problem.

Some people will have this in the Model layer of Catalyst. It's OK if all your work is guaranteed to be Catalyst. But what if it's not? What if you want to access your database from e.g. a stand alone server or a cron job?

I use DBIC ResultSets to fill out the hole between simple DBIC classes and the actual code I think that RS suits the bill in a nice way.

This is one way to have more complex database code with DBIx::Class. I'm sure there are a lot of other ways to do it. And I'm sure some people will tell me why I'm wrong :-)

But it's easy to do. Just watch.

In Project::DB::Class:
__PACKAGE__->resultset_class('Project::RS::Class');

Write methods in Project::RS::Class, e.g.

sub create_full {
        my ( $self, $args_ref ) = @_;

        $self->check_defaults($args_ref);
        $self->validate_data($args_ref);

        # Get schema
        my $schema = $self->result_source->schema;

        $schema->txn_do(
                sub {
                        # Do something
                }
        }
}

and then use it from your controller, script, whatever:

$schema->resultset('Class')->create_full($args_ref);

Friday March 02, 2007
08:37 AM

Copenhagen in flames?

Copenhagen in flames, eh?

Somehow it looks scarier in television than IRL. Unless you live within a few hundred meters from Jagtvej 69.