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

John Napiorkowski jjn1056 at yahoo.com
Sat Aug 12 05:44:54 CEST 2006


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?

--john





More information about the Catalyst-dev mailing list