[Catalyst] Elegant way to check action presence?

J. Shirley jshirley at gmail.com
Sat Jan 9 21:24:05 GMT 2010

2010/1/9 Alex Povolotsky <tarkhil at over.ru>:
> Hello!
> I'm working on a (more or less) flexible system with plugins should be
> installed just like controllers; some basic information about them
> (particulary, numerical id) must be kept in database.
> Plugins should be handle some queries in /admin/service/$servicename
> I'd like to put 'smart links' in plugin information table - i.e. if
> something handles /admin/service/$servicename/control, link exists; if no -
> instead of link text in different style is presented, telling that plugin
> has not been installed.
> construction like
> [% SET path=stype.path %]
> [% IF c.can('/admin/service/$path/control') %]
> <a href ... >
> [% ELSE %]
> message here
> [% END %]
> is ugly; maybe someone points me to some nicer idea? I was thinking of some
> function in Schema/Result/Servicetype.pm returning link or warning, but how
> do I access the Catalyst object from it? Or I just have to pass it as
> argument?
> Alex.

The way I did this is using the namespace and action, since the
namespace is configurable.


If it returns undef, the action doesn't exist in the defined namespace.


More information about the Catalyst mailing list