On 1 Jun 2011, at 19:35, BUCHMULLER Norbert wrote:
Comments welcome.
Monkey patching Catalyst::Controller is a horrible horrible horrible
idea, please don't do that!
If (for example) one were to load two Catalyst apps at once (e.g.
FCGI::Engine running multiple apps, or one mod_perl instance with two
apps), then this would result in both applications getting the
behavior, which I'm quite sure is not what you intended.
If you really need to do this, then apply the roles to the controller
_instances_ after they have been initialized.
E.g.
around setup_component => sub {
my ($orig, $self, @args) = @_;
my $instance = $self->$orig(@args);
Moose::Util::apply_all_roles($instance, 'My::Role');
return $instance;
};
This will only affect the application you load it into, rather than
all Catalyst applications sharing that memory space.
Cheers
t0m
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/