logo       

Re: RFC - C::A::Plugin - abstract base class for plugins: msg#00130

Subject: Re: RFC - C::A::Plugin - abstract base class for plugins
Bill --

On 2004-08-25, Bill Catlan <wcatlan-/E1597aS9LQAvxtiuMwx3w@xxxxxxxxxxxxxxxx> 
wrote:
>
>> The storage could be like:
>> 
>>  $self->{TT}->{instance_1}
>>  $self->{TT}->{instance_2}
>>
>
> I think we're debating around the edges now.
>
> Why separate the data store from the object? If
> instance_1 and instance_2 are refs to their objects,
> as opposed to a data store, that would be more in line
> with regular object oriented programming.  Your way,
> the plugin object needs to know which instance of the
> data store belongs to it, or which it otherwise wants
> to use at a particular time.  Instead of just
> referring to itself for data:
>
> $plugin_self_instance_1->{mydata};
>
> you need something like:
>
> $plugin_self_shared->get_mydata( {instance =>
> instance_1, data_key => mydata } );

One thing to be clear about here is that "$self" is always the CGI::App
object, never a plugin-specific object. To say there may be two
instances of a plugin object is saying the same thing as saying there
would be two instances of a CGI::Application object.  That means it's a
separate application.

If you really need access to multiple "plug-in" objects of the same type
from a CGI::Application object, then what you have is a not a plug-in,
which is defined as being additional methods for the CGI::Application
object.

Instead, this sounds like the case of accessing an other OO object.
This already commonly happens when people access CGI::Session directly,
or Data::Page, HTML::FillInForm, etc.

I think the only case that applies for plug-ins, would be the desire to
call the same method multiple times. I don't think that case needs
special consideration, though.

> Plus, why not let a plugin user be able to specify
> certain things upon creation, such as exporting or a
> tag or the label (ie, in your example "instance_1".)
>
> Even if we go with your "data store" approach, why not
> add one more level of indirection to allo
>
> $self->{TT}->{instance_2}{data}
> $self->{TT}->{instance_2}{export_flag}
> etc.

I think this is already covered. Take CGI::Application::Session for
example. For it be useful, unique parameters need to provided
that eventually go to the CGI::Session::new() routine.

That happens through session_config():
http://search.cpan.org/~ceeshek/CGI-Application-Session-0.03/lib/CGI/Application/Session.pm#session_config

If you need access to two different CGI::Session instances in the same CGI::App
project, then the plug-in methaphor breaks down. It would be clearer to 
work with CGI::Session directly in that case, creating two instances of the 
CGI::Session object as usual.

If a plug-in really wants to support multiple instances, they could
something like Ima::DBH does:

http://search.cpan.org/~tmtm/Ima-DBI-0.33/lib/Ima/DBI.pm

It creates extra method names on the fly, based on your connection parameters:

  package Foo;
  use base 'Ima::DBI';

  # Class-wide methods.
  Foo->set_db($db_name, $data_source, $user, $password);
  $dbh = $obj->db_*;      # Where * is the name of the db connection.

###########

        Mark

-- 
 . . . . . . . . . . . . . . . . . . . . . . . . . . . 
   Mark Stosberg            Principal Developer  
   mark-WmyhgDpj2fCHT8/ATrE1yw@xxxxxxxxxxxxxxxx     Summersault, LLC     
   765-939-9301 ext 202     database driven websites
 . . . . . http://www.summersault.com/ . . . . . . . .


---------------------------------------------------------------------
Web Archive:  
http://www.mail-archive.com/cgiapp-svx1JCNWaqPWzzAP45jFb16hYfS7NtTn@xxxxxxxxxxxxxxxx/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: 
cgiapp-unsubscribe-svx1JCNWaqPWzzAP45jFb16hYfS7NtTn@xxxxxxxxxxxxxxxx
For additional commands, e-mail: 
cgiapp-help-svx1JCNWaqPWzzAP45jFb16hYfS7NtTn@xxxxxxxxxxxxxxxx




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe