On 5/25/07, Jason Konrad <jason popularmedia.com>
wrote:
> I got some help from the DBIx list today which helped
me get the txn_do()
> method working for my schema which is created with the
loader
>
> ----Schema--------
> package kRadDB;
>
> use strict;
> use base qw/DBIx::Class::Schema::Loader/;
>
> __PACKAGE__->loader_options(
> relationships => 1,
> );
>
> The solution was to create a schema instance like so,
>
> my $schema = kRadDB->connect(...);
>
> Then do the transaction
>
> $schema->txn_do($coderef);
>
>
> This does accomplish what I was trying to do but aren't
there some
> connections around that I could use rather than
manually connecting each
> time I need to do this transaction?
You don't have to connect every time. Catalyst::Model: BIC::Sch
ema
connects when your catalyst application launches and does
its best to
preserve the connection for you. You can get to the schema
instance
via $c->model()
> The docs for Catalyst-Model-DBIC-Schema say
>
> # to access schema methods directly:
> $c->model('FilmDB')->schema->source(...);
>
>
> When I try a similar thing,
>
> $c->model('kRadDB')->schema
>
> I get this error " Can't call method
"schema" without a package or object
> reference"
You need to ask for the model name that inherits from
Catalyst::Model: BIC::Sch
ema, the one that has __PACKAGE__->config(
schema_class => 'kRadDB', config_info => '...' ) in
it, not the schema
class.
--
Eden Cardim
Instituto Baiano de Biotecnologia
Núcleo de Biologia Computacional e Gestão de Informações
Biotecnológicas
Laboratório de Bioinformática
_______________________________________________
List: Catalyst lists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalyst lists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/
|