[Catalyst] Inheritance problem in "used" model

Sean Davis sdavis2 at mail.nih.gov
Tue Dec 6 16:47:33 CET 2005


I have the following inheritance structure for a couple of model classes set
up.  I can use these model classes outside of Catalyst without problems.
However, when I "use" OligoMap::Oligo in a controller

    use OligoMap::Oligo;
    my $oligo = OligoMap::Oligo->new($c->req->snippets->[0]);


I get:

Caught exception "Can't locate object method "sqlengine" via package
"OligoMap::Oligo" ....


Why is my sqlengine method not inherited under catalyst but is outside of
catalyst?  (There is a problem with my concept of inheritance, likely, but I
can't figure out what that is.)

Thanks,
Sean


package OligoMap;
use strict;

use DBIx::SQLEngine;
use Data::Dumper;

sub new {
    my $proto = shift;
    my $class = ref($proto) || $proto;

    my $self  = {};
    bless($self,$class);

    return($self);
}

sub sqlengine {
    my $self = shift;

    if (exists($self->{_sqlengine})) {
    return($self->{_sqlengine});
    }
    my $sqle = DBIx::SQLEngine->new('dbi:Pg:dbname=annodb4;host=sherlock',
                    'sdavis',
                    'mic2222') or die;
    $self->{_sqlengine} = $sqle;
}

package OligoMap::Oligo;
use strict;

use OligoMap;

our @ISA = (qw/OligoMap/);

sub new {
    my $proto = shift;
    my $oligo = shift;
    my $class = ref($proto) || $proto;

    my $self  = {};
    bless($self,$class);

    $self->SUPER::new(@_);

    $self->initialize($oligo);

    return($self);
}

sub cghProbes {
    my $self = shift;

    if (exists($self->{_cghprobes})) {
    return ($self->{_cghprobes});
    }

    my $sql = 'select chrom,tstart,tend,strand,score,max_block_size,db from
oligo.cghprobes natural join oligo.oligo where oligo=?';
    $self->{_cghprobes} =
    $self->sqlengine->fetch_select(sql=>[$sql,$self->name]);
    return($self->{_cghprobes})
}





More information about the Catalyst mailing list