Bill Catlan wrote:

Just to set a reference point, do we all agree that
everything we discussed would benefit from some agreed
upon method of preventing namespace conflicts between
plugins - no matter what space they are brought into?

Ok, some more thoughts and ideas on all of this...

Right now in the existing, alpha plugins, they do something like this to avoid namespace issues....

  package MyApp;
  use base 'CGI::Application';
  use CGI::Application::Plugin::TT;
  use CGI::Application::Plugin::Config::Simple;

  [snip]
  $self->tt_process(...);
  my $param = $self->config_param(..);

The problems with this is that when you create a plugin you have to make sure that you don't export a method that any other existing plugin could export. This would be a headache. Not to mention that if you're plugin wants to try and have some sort of parameters that it saves somewhere you'll have to break the encapsulation of the the C::A application module and try to put something in it's internal hash. Lot's of problems with this...

So, another idea I had was, that upon 'using' a plugin, it would export only one method (which the user of the plugin would name) into the application's namespace. This method would act as an accessor to every other method you 'export' and also as a constructor for your plugin (if you need one). Ok, example time. I'm redoing the above example with this...


package MyApp; use base 'CGI::Application'; use CGI::Application::Plugin::TT name => 'tt'; use CGI::Application::Plugin::Config::Simple name =>'conf';

 [snip]
 $self->tt->process(...);
 my $param = $self->conf->param(..);

This one method that we export could even implement an object cache. If it's called the first time it will call the plugin's new() method and store the object in some agreed upon place. Then the next time it is called it would just retrieve that object.

This would eliviate the problem of having to use the application module's internal hash for storage since each plugin would actually be an object in itself. There would be no namespace issues between methods since the user picks the name by which each plugin is accessible.

Ok, now time for questions, comments, verbal abuse...

--
Michael Peters
Developer
Plus Three, LP


--------------------------------------------------------------------- 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]



Reply via email to