[Catalyst-dev] Is it okay to re-dispatch sub new in a custom controller?

Matt S Trout dbix-class at trout.me.uk
Sat Aug 12 22:56:32 CEST 2006


John Napiorkowski wrote:
> Hi,
> 
> I'm writing a custom controller for a long belated wiki system and would like to perform some one time only initialization of the controllers properties.  Usually when I do initialization in a class I have the new method call a initialize method to set stuff I need.
> 
> What I am trying to find out if this is okay to redispatch new in a subclass of Catalyst::Controller::Base using NEXT like in this example:
> 
> sub new
> {
>     my $self = shift;
>     my $new = $self->NEXT::new(@_);
> 
>     $new->initialize()
> 
>     return $new;
> }
> 
> sub initialize
> {
>     $self = shift;
>     $self->{something} = "1111";
>     #More setup stuff going on
> }
> 
> Now, I've tried this and it all works okay, but I wanted to find out if this way is okay as in terms of forward compatibility, or if the new method is offlimits for custom controllers and plugins.  If so is there a list somewhere around of the methods that are OK for re-dispatch?

It's a class. You're supposed to subclass it. Don't be silly :)



More information about the Catalyst-dev mailing list