[Catalyst] Config-only components

Matt S Trout dbix-class at trout.me.uk
Thu Feb 14 14:10:09 GMT 2008


On Wed, Feb 13, 2008 at 09:30:15PM -0700, Todd Harris wrote:
> 
> On Feb 12, 2008, at 12:09 AM, Dagfinn Ilmari Mannsåker wrote:
> 
> >Hi all,
> >
> >Castaway mentioned the idea of having components defined entirely by
> >config entries, without the need for any actual class files on disk,  
> >and
> >I was bored, so I went ahead and implemented it.
> >
> >For each config key matching ^([MVC]|Model|View|Controller):: it  
> >checks
> >if the corresponding component already exists, and if it doesn't it
> >creates it on the fly. The base class is set to
> >->config->{$component}->{base_class} if it exists, Catalyst:: 
> >$component
> >(with [MVC] expanded to the full component type) otherwise.
> >
> >Here's the patch against 5.70/trunk, feedback welcome.
> 
> <snip>
> 
> Looks interesting. I'm dynamically registering a large number of  
> actions based on configuration entries.  This is a great  
> simplification, but also seems like a bit of a hack.  I'm overriding  
> render_actions() to accomplish this.

Then you've done something wrong. The only bit that's an issue is
getting the namespace right - which can be done by passing a
default namespace to new(), or maybe better still telling a component
where it is in the tree when it's created so the controller defaulting
code can use that rather than its own class name.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst mailing list