[Catalyst] Database schema -- Can't locate object method "new" via package

Sarah Berry berry.sarah at gmail.com
Fri Jun 16 20:14:10 CEST 2006


Matt,

Thanks for the suggestions. But

my $schema = $c->model("SLogDB")->schema;

gives me

Caught exception in vieSEB::Controller::dbixdemo->default "Can't
locate object method "schema" via package "vieSEB::Model::SensorLogDB"

As far as the classes, "tblsmaps" is the name of a table in the
database that contains information on the location of sensors. I'm
trying to search this table, which was set up by the schema loader if
I did that part right (which is far from certain).

Sarah


On 6/16/06, Matt S Trout <dbix-class at trout.me.uk> wrote:
> Sarah Berry wrote:
> > As far as documentation, I've been working from the introduction to the
> > DBIx class at
> > http://www.annocpan.org/~MSTROUT/DBIx-Class-0.06999_02/lib/DBIx/Class/Manual/Intro.pod
> > <http://www.annocpan.org/~MSTROUT/DBIx-Class-0.06999_02/lib/DBIx/Class/Manual/Intro.pod>
> > , as well as referencing a great thread from the list archives
> > (http://www.gossamer-threads.com/lists/catalyst/users/7463?search_string=schema%20loader
> > <http://www.gossamer-threads.com/lists/catalyst/users/7463?search_string=schema%20loader>)
> > where there's a detailed example of what files go in what Catalyst
> > folders (Model vs. Schema, etc).
> >
> > I put the following command on my page (dbixdemo.pm
> > <http://dbixdemo.pm>), and it rendered fine in the browser:
> >               my $schema = $c->model("SLogDB");
>
> my $schema = $c->model("SLogDB")->schema;
>
> > When I tried to follow it up with
> >               my $attempt = $schema->resultset('tblsmaps')->find(14);
> > I got the error
> >       Caught exception in vieSEB::Controller::dbixdemo->default "Can't
> > locate object method "resultset" via package "vieSEB::Model::SLogDB"
>
>
> why not just do
>
> my $map = $c->model("SLogDB::tblsmaps")->find(14);
>
> ?
>
> Also, "tblsmaps" is an awful name for a class. If it's a map class, call it "Map".
>
> > Maybe I have the wrong plugin installed or something. Jess, in your
> > example, what should Foo be? A table in the database? A query you set up
> > somewhere else?
> >
> > Thanks again,
> >
> > Sarah
> >
> >
> >
> > On 6/16/06, *Jess Robinson* <castaway at desert-island.demon.co.uk
> > <mailto:castaway at desert-island.demon.co.uk>> wrote:
> >
> >
> >
> >     On Thu, 15 Jun 2006, Kevin Old wrote:
> >
> >      > On 6/15/06, Sarah Berry < berry.sarah at gmail.com
> >     <mailto:berry.sarah at gmail.com>> wrote:
> >      >> I'm trying to learn how to use the database plugins,
> >     specifically DBIx. I
> >      >> set up my schemas to load from an existing database (hopefully),
> >     and now I
> >      >> want to test it out to see if I did that right. So I put the
> >     following lines
> >      >> into a page called dbixdemo.pm <http://dbixdemo.pm>, in the
> >     "default" function:
> >      >>
> >      >>         my $schema = VieSEB::Schema::SLogDB->new();
> >      >>         my $crazy_attempt =
> >      >> $schema->resultset('SLogDB')->find(14);
> >      >
> >      > Hi Sarah,
> >      >
> >      > Make your calls in Controllers like this:
> >      >
> >      > $c->model("VieSEB::Schema::SLogDB")->new();
> >      > $c->model("VieSEB::Schema::SLogDB")->search();
> >      > $c->model("VieSEB::Schema::SLogDB")->find();
> >      >
> >
> >     Or, more sanely:
> >
> >     my $schema = $c->model("SLogDB");
> >     my $attempt = $schema->resultset('Foo')->find(14);
> >
> >     or even:
> >
> >     my $attempt = $c->model('SLogDB::Foo')->find(14);
> >
> >     You shouldnt need to call ->new, as Catalyst does that for you, and
> >     stores
> >     the result, which you can retrieve using $c->model.
> >
> >     Are there not examples in the Catalyst::Model::DBIC::Schema pod?
> >
> >     Jess
> >
> >
> >     _______________________________________________
> >     List: Catalyst at lists.rawmode.org <mailto:Catalyst at lists.rawmode.org>
> >     Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> >     Searchable archive:
> >     http://www.mail-archive.com/catalyst@lists.rawmode.org/
> >     Dev site: http://dev.catalyst.perl.org/
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > List: Catalyst at lists.rawmode.org
> > Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> > Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
> > Dev site: http://dev.catalyst.perl.org/
>
>
> --
>       Matt S Trout       Offering custom development, consultancy and support
>    Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
> Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information
>
> + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>



More information about the Catalyst mailing list