[Catalyst] setup() called twice
Matt Lawrence
matt.lawrence at ymogen.net
Wed Jun 20 11:16:52 GMT 2007
Matt S Trout wrote:
> On Tue, Jun 19, 2007 at 06:19:30PM +0100, Matt Lawrence wrote:
>
>> Matt S Trout wrote:
>>
>>> Still completely broken.
>>>
>>> Read half a dozen plugins' setup methods and come back when you have a
>>> clue.
>>>
>> Nothing like a bit of random abuse to spark off a bit of development work...
>>
>
> Shame it didn't spark off you actually going and reading what I suggested you
> did before you wasted your time and the list's.
>
Well I can't say I didn't ask for that.
> Tell you what, I'll read the setup methods for you and spell it out:
>
> Now do you understand why your approach isn't going to work?
>
>
Admittedly my first suggestions were naive to say the least, and looking
back now they are unnecessarily terse. I didn't intend to seem
confrontational, it just seemed odd at first glance that there was a
known set of methods that needed to be called, but because of the MRO
unwanted side-effects could occur.
For what it's worth, the patch I sent actually does respect the MRO, it
calls the first defined setup method in the plugin list directly,
bypassing MyApp. I only realised on the tube home that it would cause an
infinite loop with real plugins (as opposed to the ones in the test
suite I now see don't call NEXT::setup). In my haste I didn't clock that
the plugins necessarily appear before Catalyst in the MRO and I imagined
that the tests were passing because Catalyst::setup was being bypassed
too. Once you replace the temporary setup no-op, it is pretty much
functionally equivalent to redefining MyApp::setup.
It strikes me that there's another case where a setup method could be
called twice: if the application's base class is a Catalyst subclass
with an overridden setup. I guess this isn't particularly likely, though.
Anyway, apologies all round for half-baked suggestions. I'll return to
lurking..... Now.
Matt
More information about the Catalyst
mailing list