[html-formfu] inheritance question
Malcolm
mjh-formfu at liminalflux.net
Thu Feb 26 01:07:46 GMT 2009
On Monday 23 February 2009, Carl Franks wrote:
> > Though it would probably help if I got my examples the correct way
> > around.
> >
> > package MySite::Controller::Profile;
> > use parent qw(Catalyst::Controller::HTML::FormFu
> > MySite::Controller::Base); works.
> >
> > package MySite::Controller::Profile;
> > use parent qw(MySite::Controller::Base
> > Catalyst::Controller::HTML::FormFu); does not.
> Without the code for MySite::Controller::Base, I can only guess that
> it's inheriting from Catalyst::Controller which has a create_action sub,
> meaning that C::C::HTML::FormFu's won't be called.
That is what was happening (though Base was inheriting from a third class,
which is what was inheriting from Catalyst::Controller, same end result
though). As the other class didn't use create_action, everything worked with
things ordered so FormFu gets the call.
On Monday 23 February 2009, Byron Young wrote:
> I put this bit of code in my multiply-inherited controllers to make sure
> everybody's create_action sub is called:
>
> use Class::C3;
> sub create_action {
> my $self = shift;
>
> return $self->maybe::next::method(@_);
> }
>
> It works for me. If somebody has a better way to get around the problem,
> I'd love to hear it.
Thanks.
It does seem somewhat awkward, as you'd have to do the same thing for every
function. (Though it's much cleaner than the equivalent in C++, which is the
other language I have to use regularly).
Maybe there's something in Moose that would do it, but I haven't finished
wrapping my head around Moose yet.
More information about the HTML-FormFu
mailing list