On 5/25/07, Jason Konrad <[EMAIL PROTECTED]> 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::DBIC::Schema
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::DBIC::Schema, 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: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to