Cees -- On 2004-07-27, Cees Hek <[EMAIL PROTECTED]> wrote: > > It's been fairly quiet on the development side of things with > CGI::Application, so I thought I would try to stir things up again ;) > > A little while ago, I noticed some talk on the Class::DBI list about a > plugin architecture for Class::DBI. Someone actually followed through > on the discussion and built Class::DBI::Plugin, which according to the > docs is an "Abstract base class for Class::DBI plugins". > > The implementation is very simple, and I think is worthwhile looking at > for CGI::Application. So I took about an hour out of my usually busy TV > watching schedule and threw together CGI::Application::Plugin. > > It simplifies and standardizes the way a plugin can be built for > CGI::Application, and it works completely outside of the > CGI::Application codebase (ie no patches necesary). It avoids the > annoyances of building a big inheritance tree for the plugins you want > to use by copying a given set of methods into the callers namespace. No > exporting or name space munging needs to be done by the plugin modules, > as this is done automatically. > > As an example of how it works, I have put up new versions of the > CGI::Application::Session and CGI::Application::TT modules on my website > (http://cees.crtconsulting.ca/perl/modules/), as well as a tarball > containing the actual CGI::Application::Plugin module. I won't upload > this stuff to CPAN unless there is some positive discussion about this, > hence it is just on my website for now. If people don't like it, I can > just scrap it without polluting the CPAN, no harm done. > > I have attached the pm file for those that don't want to pull down the > tarball. I've also inlined it, since I have had trouble sending > attachments to this list in the past.
I agree a standardized plugin system would benefit C::A. With some current "add ons", it's not clear what their relationship is. (i.e: C::A::Session, C::A::ValidateRM). I think the simplest solution for plugins to work like C::A::ValidateRM does. I don't think the proposed base class really helps this. It just does the exporting in a different way. It uses attributes to do this, which are less well known than the standard EXPORT method. I don't think it's too much of ask of plugin writers to use standard Exporter techniques-- export public routines and hide private ones. I propose the following alternate solution. 1. Rename and refactor existing plugin modules to be consistent: - ::Session - ::ValidateRM - ::Config::Simple - ::TT 2. Simply update the POD of CGI::Application to explain what's going on, both for users and writers of plugins. Something like this: =head1 PLUG-INS CGI::Application has a plug-in architecture that is easy to use and easy to develop new plug-ins for. =head2 Existing plug-ins Here are some plug-ins that have already been developed for CGI::Application. For a current complete list, please consult CPAN: http://search.cpan.org/search?query=Class%3A%3ADBI%3A%3APlugin&mode=module =over 4 =item * L<CGI::Application::Plugin::Session> - Integration with L<CGI::Session> =item * L<CGI:::Application::Plugin::ValidateRM> - Integration with Data::FormValidator and HTML::FillInForm =item * L<CGI::Application::ValidateRM::TT> - Use L<Template::Toolkit> as an alternative to HTML::Template. =item * L<CGI::Application::Plugin::Config::Simple> - Integration with Config::Simple. =back Consult each plug-in for the exact usage syntax. =head2 Writing Plug-ins Writing plug-ins is simple. Simply create a new package, and export the methods that you want to become part of a CGI::Application project. See L<CGI::Application::Plugin::ValidateRM> for an example. You only need to keep in mind that your extension should "play well with others". The method names exported should be unique. Also, additions to the CGI::Application object should be designed not to conflict with other potentional plug-ins. For that reason, it's recommended that you add a a hash key to the CGI::Application which reflects the name of your plug-in, such as: $self->{'Config::Simple'} ########### Thoughts? Mark -- http://mark.stosberg.com/ --------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
