Let's extend Class::Trigger with CGI::App's plugin design

markjugg on 2005-08-06T17:41:07

As I worked on a new plugin system for HTML::Template, I recycled code from CGI::Application's new plugin system.

As I reflected on this, CGI::Application has developed a nice plugin system which is easily re-usable on it's own.

It is most similar to Class::Trigger, but I think the CGI::App solution is more advanced for these reasons:

  • We look up the inheritance tree for more callbacks to execute
  • We allow arguments to be passed into the callbacks, customizing how each callback can work, and creating clearer, more explicit syntax than passing through the object.
  • We have a specific callback ordering, and we expect to soon solve the problem of making this ordering to be sufficiently flexible to address most plugin needs.
  • Class::Trigger requires your object be implemented as blessed hashref (Gasp!). We could solve this in our implementation by adding a method for 'installed_callbacks()', which could be trivially overridden if the callbacks needed to be stored in the object a different way.
So I would like to move CGI::App's plugin system into it's own module, which wouldn't change anything from a user's perspective, except perhaps where the related documentation is located.

I could see what we have possibly being merged into a future enhanced version of Class::Trigger, which CGI::App would then have it's own plugin for, to keep compatibility with the names we've already established.

Collaborators welcome! Let's keep discussing it on the CGI::Application mailing list and #cgiapp on irc.perl.org.

Mark