[Catalyst] Accessing $schema in Model glue class

Tobias Kremer list at funkreich.de
Thu Jan 24 15:03:45 GMT 2008


Quoting Tobias Kremer <list at funkreich.de>:
> AFAICT, MyApp::Model::Schema class would be a good place to issue a
> $schema->default_resultset_attributes( { cache_object ... } ) call
> which is needed by DBIx::Class::Cursor::Cached. Is there an easy way to
> access $schema from within MyApp::Model::Schema?

Realizing that MyApp::Model::Schema is already just a subclass of
C::M::DBIC::Schema (doh!) I came up with the following solution that just
overrides new():

sub new {
    my $self = shift->NEXT::new(@_);
    $self->schema->default_resultset_attributes( { ... } );
    return $self;
}

--Tobias



More information about the Catalyst mailing list