[Catalyst] Re: use for expand_modules

Tomas Doran bobtfish at bobtfish.net
Mon Aug 8 20:51:01 GMT 2011

This is brilliant, and exactly what I was looking for.

Thank you _so much_ for taking the time to write all of this up.

On 8 Aug 2011, at 10:13, Gianni Ceccarelli wrote:

> - How the &%$%$^# did you think this was a good idea?
>  Well, it *is* documented :) And it seems to be the obvious hook:
>  when loaded, my component creates more components…

Yes, indeed!

I have built a few systems like this, except I've always used hooking  
after setup_components to read config and setup the components I have  
generated via MMC->create, embedding the logic to do the scaffolding  
into MyApp.

Using expand_modules in the way you have to allow components to plug  
their controllers is a great hook to use. :_)

> Questions:
> - am I insane? :)

No, not at all.

You have a fairly scary use-case, but I think what you've done is  
perfectly reasonable.

> - is there a better / cleaner / more future-proof way of getting the
>  same result?

At a word, no. There are other techniques you could be using to get  
the same results, but they're likely to have the same sort of issues  
(i.e. we'll have to think hard about back-compat).

I was more doing a survey to find out how people are using it in real  
life, as the current tests for the feature are woefully inadequate for  
testing anything other than the most trivial of use-cases.

We can now write some tests for a more advanced use-case like yours in  
the Catalyst test suite, and then verify that everything you're doing  
is still possible / working when we shift the internals around (or at  
worst, that if we need to break something, we can explicitly document  
it, and how to get around it in the new version)..

> - will the "much better solution" that t0m hinted at still allow me
>  this kind of contortions?


In fact it should make doing them significantly easier and more  
flexible, with less hacks involved.

The idea is (and there is a very active branch working on) porting the  
component discovery and loading to Bread::Board, allowing you much  
more flexibility in how things are wired up.


More information about the Catalyst mailing list