Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Tuesday February 21, 2006
01:41 PM

New version of Catalyst

[ #28759 ]

A new version of Catalyst was released today. Amongst other things it fixed a problem I had with plugins. Basically, a plugin name pretty much had to start with Catalyst::Plugin::. If you wrote My::Plugin::DoesTheDishes, how do you get Catalyst to recognize that?

Well, there are a few ways. You could write a wrapper whose name starts with Catalyst::Plugin:: and redispatches to your plugin. That's kind of ugly. You could also inherit directly from the plugin, but that's ugly, too. You could also use a MyApp->plugin($name, $plugin); which is fairly clean, but appears to deny the plugin access to request phases.

In short, there are a whole bunch of different ways to do something subtly wrong. I want one to do the right thing. How are plugins normally loaded?

use Catalyst qw(

Of course, those are really Catalyst::Plugin::DateTime and Catalyst::Plugin::Static::Simple. I want, as much as possible, to drive all plugin creation through the same process. That way, if we change how plugins are used (eliminate MI, please!), then we have one spot to do it. So I committed a patch which lets you do this:

use Catalyst qw(

That might not seem like that big of a deal, but the immediate payoff came when I wrote the tests. I needed to know which plugins were loaded and in Catalyst, there was no correct way of doing that. With the above patch, you get a bit of introspection:

foreach my @plugin ($c->registered_plugins) {

if ($c->registered_plugins('Static::Simple')) {

if ($c->registered_plugins('Catalyst::Plugin::Static::Simple')) {

I have a slight reservation about allowing non-fully-qualified plugin names (e.g., "Static::Simple") to be used with this method, but since those are how most folks see the names, it felt more consistent.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I am curious why you wouldn't want to keep it in the "Catalyst::plugin::" naming convention? Isn't that what naming conventions are for?
    • Let's say I create MyApp::Plugin::Foo. People can install that and there's no danger that someone else will create a Catalyst::Plugin::Foo which will conflict with that. In fact, they could use both at the same time:

      use Catalyst qw(Foo +MyApp::Plugin::Foo);