List Info

Thread: Catalyst and transactions




Catalyst and transactions
country flaguser name
United States
2007-05-25 15:51:22
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?

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"

Thanks for any advice/help,
 Jason


_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: Catalyst and transactions
user name
2007-05-25 16:16:49
Try this:
$c->model('kRadDB')->result_source->schema

On 5/25/07, Jason Konrad <jasonpopularmedia.com>
wrote:
> 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?
>
> $c->model('kRadDB')->schema
>
> I get this error " Can't call method
"schema" without a package or object
> reference"

-- 
-----------------------------------------------------
Evaldas Imbrasas
http://www.imbrasas.com

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: Catalyst and transactions
user name
2007-05-25 16:36:07
On 5/25/07, Eden Cardim <edencardimgmail.com> wrote:
> 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.

oops, s/config/connect/

-- 
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: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: Catalyst and transactions
user name
2007-05-25 16:34:55
On 5/25/07, Jason Konrad <jasonpopularmedia.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: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )