[Catalyst] External plugins (continued)

Ovid publiustemp-catalyst at yahoo.com
Sat Feb 18 00:04:09 CET 2006


--- Brandon Black <blblack at gmail.com> wrote:

> Anyways, what I meant a couple of emails ago was: the plus-sign still
> means literal classnames, but the non-plus-sign ones also search
> MyApp::Plugin in addition to Catalyst::Plugin.  I don't think it
> introduces anything really horrible to have the non-plus-sign ones
> get searched in two different namespaces would it?

I don't see a problem with and and it wouldn't be too terribly hard to
implement.  In the meantime, here's my proposed plugin patch:

  http://rafb.net/paste/results/Pcv25r41.html

>From the code, it appears that this:

  MyApp->plugin($accessor, $plugin, @args);

Creates a delegation to the plugin but does *not* inherit from it.  I
have kept this behavior.  Now you can do this:

  use Catalyst qw(
    DateTime
    +Fully::Qualified::Plugin::Name
  );
  MyApp->plugin('foo', 'Some::Other::Plugin', @args);

And then you can either fetch a list of all plugins:

  $c->registered_plugins;

Or determine if a given plugin exists:

  if ($c->registered_plugins('DateTime')) {...}
  # same as
  if ($c->registered_plugins('Catalyst::Plugin::DateTime')) {...}
  # or 
  if ($c->registered_plugins('Fully::Qualified::Plugin::Name')) {...}

Tests are included.  Please let me know what you think.

Cheers,
Ovid

-- 
If this message is a response to a question on a mailing list, please send follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/



More information about the Catalyst mailing list