[Catalyst] Newbie Catalyst::Model::Factory

Michael Peck mpeck at pobox.com
Tue Oct 23 17:52:07 GMT 2007

I am new to Catalyst, but have been successful at creating simple DBIC CRUD
apps.  Now, I am trying something different...  I want to use an
Archive::Tar::File object as a model.  I have created my model as:

package LogManager::Model::Tar;

use strict;
use warnings;
use base 'Catalyst::Model::Factory';

    class       =3D> 'Archive::Tar::File',
    constructor =3D> 'new',


The Archive::Tar::File constructor (new) requires a filename be passed e.g.,
new( file =3D> $path ).  In a controller, I have tried:

sub view : Local {
    my ( $self, $c, $file ) =3D @_;

    LogManager->config->{'Model::Tar'} =3D {
        class =3D> 'Archive::Tar::File',
        args  =3D> {
            file =3D> "c:\\temp\\logs\\$file",
    my $tarball =3D $c->model('LogManager::Tar');
    if( $tarball ) {
        my @items =3D $tarball->get_files;
        $c->stash->{items} =3D @items;
    else {
        $c->stash->{error_msg} =3D "Couldn't instantiate LogManager::Tar
    $c->stash->{template} =3D 'log/view.tt2';

The server started without error, and I called it with *"*

I have, unsuccessfully, tried several other scenarios, but all I get is an
undefined object, resulting in $c->stash->{error_msg} being set to "Couldn't
instantiate LogManager::Tar model".  Any pointers in the right direction are
greatly appreciated.

BTW, Catalyst is and awesome framework!

Mike Peck
mpeck at pobox.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20071023/31170=

More information about the Catalyst mailing list