[Catalyst] My experience porting to CataMoose
Matt S Trout
dbix-class at trout.me.uk
Wed May 13 15:55:11 GMT 2009
On Wed, May 13, 2009 at 04:13:06AM +0200, Sebastian Willert wrote:
> On Wed, 2009-05-13 at 07:21 +0900, Daisuke Maki wrote:
> > >> 2. Hooking to methods that Plugins use via method modifiers breaks
> > >> method dispatch
> > >>
> > >> I got bit by this while depending on Catalyst::Plugin::Unicode, and
> > >> trying to hook a custom error handling mechanism at finalize().
> > >
> > > <snip explanation>
> > >
> > > Hmm, that certainally looks like a bug to me..
> > >
> > > Any chance that I could get you to write a test case or two for this issue?
> >
> > I get it now, it has to do with when setup() and method modifiers run:
> >
> > <snip example code>
> >
> > If you intend to use Moose's method modifiers in your app, do so
> > /AFTER/ Catalyst->setup has been called.
> >
> > or some such
>
> First of all: thanks for the pointer, you have ended a lot of hair
> pulling for me. But IMO this is not just a common gotcha but a serious
> bug.
Wrong, sorry. It's an inevitable caveat. The point is that plugin setup
changes the app's @ISA, so it simply isn't safe to run modifiers before
->setup, or more specifically until after ->setup_plugins.
> I have a few plugins I am trying to convert to Moose::Role's that
> desperately need both
> before 'setup_components'
> and
> after 'finalize'
>
> This just isn't going to work one way or the other :(
Fortunately, setup_plugins happens -before- setup_components so you can
apply a role any time after that and it'll all work fine.
> Maybe I can whip up some testcases tomorrow ..
Maybe you can whip up some documentation tomorrow?
Though it would be nice if modifier application before ->setup_plugins
produced a warning explaining why that's bad, wrong, and not going to work.
--
Matt S Trout Catalyst and DBIx::Class consultancy with a clue
Technical Director and a commit bit: http://shadowcat.co.uk/catalyst/
Shadowcat Systems Limited
mst (@) shadowcat.co.uk http://shadowcat.co.uk/blog/matt-s-trout/
More information about the Catalyst
mailing list