[Catalyst] Configuring Catalyst::Model::DBIC::Schema from YAML
Jon Warbrick
jw35 at cam.ac.uk
Tue Oct 3 13:11:05 CEST 2006
On Mon, 2 Oct 2006, Matt S Trout wrote:
> Jon Warbrick wrote:
> > But for some reason my Catalyst::View::MicroMason
> > view, called Lookup::View::MicroMason _isn't_ successfully configured - it
> > behaves as if the extra mixins are not present. Anyone any idea why?
>
> Yes. Because it's broken.
>
> my @Mixins = @{ $self->config->{Mixins} || [] };
>
> should be
>
> my @Mixins = @{ $self->{Mixins} || [] };
>
> and similarly throughout the module.
>
> I've cc'ed the author on this message in the hopes he'll fix it :)
Here's a patch, in effect a rewrite of new() based on
Catalyst::View::TT::new(), which _appears_ to resolve the problem though I
still don't feel I entirely understand what should be happening here...
Jon.
--- MicroMason.pm.orig 2006-10-03 09:59:40.000000000 +0100
+++ MicroMason.pm 2006-10-03 11:49:48.000000000 +0100
@@ -5,7 +5,7 @@
use Text::MicroMason;
use NEXT;
-our $VERSION = '0.03';
+our $VERSION = '0.03_001';
__PACKAGE__->mk_accessors('template');
@@ -53,17 +53,25 @@
=cut
sub new {
- my $self = shift;
- my $c = shift;
- $self = $self->NEXT::new(@_);
+ my ( $class, $c, $arguments ) = @_;
my $root = $c->config->{root};
- my @Mixins = @{ $self->config->{Mixins} || [] };
+ my $config = {
+ template_root => "$root",
+ %{ $class->config },
+ %{ $arguments },
+ };
+
+ my $self = $class->NEXT::new(
+ $c, { %$config },
+ );
+
+ $self->config($config);
+
+ my @Mixins = @{ $config->{Mixins} || [] };
push @Mixins, qw(-TemplateDir -AllowGlobals);
- my %attribs = %{ $self->config };
- $self->template( Text::MicroMason->new( @Mixins,
- template_root => "$root",
- #allow_globals => [qw($c $base $name)],
- %attribs ) );
+ delete ($config->{Mixins});
+
+ $self->template( Text::MicroMason->new( @Mixins, %$config ));
return $self;
}
--
Jon Warbrick
Web/News Development, Computing Service, University of Cambridge
More information about the Catalyst
mailing list