RE: Class::DBI::Plugin

[prev] [thread] [next] [Date index for 2004/06/30]

From: Addison, Mark
Subject: RE: Class::DBI::Plugin
Date: 16:17 on 30 Jun 2004
This is a multi-part message in MIME format.

----=_NextPart_ST_17_20_57_Wednesday_June_30_2004_15476
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

From: Jean-Christophe Zeus
>
> In the thread "abstract search count" I volunteered writing an abstract 
> base class for cdbi plugins. The reason for this is to make writing=20
> plugins easier, i.e. no symbol table hackery and no (well, no too much) 
> knowledge about the internals of Class::DBI.
>
> In the thread mentioned above, Stephen Quinney proposed using code=20
> attributes to specify which methods of the plugin subclass should be=20
> "plugged" in the caller's package.
>
> My proposals are as follows:
>
> 1) Methods with the attribute "Plugged" are exported,
>
> 2) The optional constant SQL is used for setting SQL in the caller's=20
> package.
>
> Here is an example (abridged):
>
> package Class::DBI::Plugin::AbstractCount;
>
> use base 'Class::DBI::Plugin';
> use constant SQL =3D> ( count_search_where =3D> $SQL );
> sub count_search_where : Plugged
> {
>    my $class =3D shift;
>    # ...
>    $class->sql_count_search_where( ... );
> }
>
> I refactored the original version of this plugin (which didn't inherit
> from Class::DBI::Plugin), and that cleaned it up a lot.
>
> Of course there are lots of features which could be added, but I think
> it's already quite useful, so I will upload it to CPAN. Is it OK for
> everyone if I use this name? Any comments on the interface?

Looks good :) The only thing I find a bit odd is using a constant for
the SQL. Why did you do it this way? Why not just use a
Class::DBI::Plugin::set_sql that delegates to the class your plugged
into? hmmmm its a complile time thing isn't it...

Or maybe an init_plugin method. Could also be usefull if the plugin wants
to add class data, TEMP columns etc.
e.g.

 sub init_plugin {
     my $class =3D shift;  # Class your plugged into
     $class->set_sql( count_search_where =3D> "..." );
     $class->mk_classdata('_plugin_search_where_foo');
 }

(Apologies if this was covered in the 'abstract search count' thread)

mark



This email (and any attachments) is intended solely for the individual(s) t=
o whom addressed. It may contain confidential and/or legally privileged inf=
ormation. Any statement or opinions therein are not necessarily those of IT=
N unless specifically stated. Any unauthorised use, disclosure or copying i=
s prohibited. If you have received this email in error, please notify the s=
ender and delete it from your system. Security and reliability of the e-mai=
l and attachments are not guaranteed. You must take full responsibility for=
 virus checking.



Independent Television News Limited,=20

Registered No. 548648 England,

VAT Reg. No: GB 756 2995 81,=20

200 Gray's Inn Road, London WC1X 8XZ,

Telephone: 020 7833 3000.

----=_NextPart_ST_17_20_57_Wednesday_June_30_2004_15476
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Diso-8859-=
1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version 6.5.6980.19"=
>
<TITLE>RE: Class::DBI::Plugin</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=3D2>From: Jean-Christophe Zeus<BR>
&gt;<BR>
&gt; In the thread &quot;abstract search count&quot; I volunteered writing =
an abstract<BR>
&gt; base class for cdbi plugins. The reason for this is to make writing<BR=
>
&gt; plugins easier, i.e. no symbol table hackery and no (well, no too much=
)<BR>
&gt; knowledge about the internals of Class::DBI.<BR>
&gt;<BR>
&gt; In the thread mentioned above, Stephen Quinney proposed using code<BR>
&gt; attributes to specify which methods of the plugin subclass should be<B=
R>
&gt; &quot;plugged&quot; in the caller's package.<BR>
&gt;<BR>
&gt; My proposals are as follows:<BR>
&gt;<BR>
&gt; 1) Methods with the attribute &quot;Plugged&quot; are exported,<BR>
&gt;<BR>
&gt; 2) The optional constant SQL is used for setting SQL in the caller's<B=
R>
&gt; package.<BR>
&gt;<BR>
&gt; Here is an example (abridged):<BR>
&gt;<BR>
&gt; package Class::DBI::Plugin::AbstractCount;<BR>
&gt;<BR>
&gt; use base 'Class::DBI::Plugin';<BR>
&gt; use constant SQL =3D&gt; ( count_search_where =3D&gt; $SQL );<BR>
&gt; sub count_search_where : Plugged<BR>
&gt; {<BR>
&gt;&nbsp;&nbsp;&nbsp; my $class =3D shift;<BR>
&gt;&nbsp;&nbsp;&nbsp; # ...<BR>
&gt;&nbsp;&nbsp;&nbsp; $class-&gt;sql_count_search_where( ... );<BR>
&gt; }<BR>
&gt;<BR>
&gt; I refactored the original version of this plugin (which didn't inherit=
<BR>
&gt; from Class::DBI::Plugin), and that cleaned it up a lot.<BR>
&gt;<BR>
&gt; Of course there are lots of features which could be added, but I think=
<BR>
&gt; it's already quite useful, so I will upload it to CPAN. Is it OK for<B=
R>
&gt; everyone if I use this name? Any comments on the interface?<BR>
<BR>
Looks good :) The only thing I find a bit odd is using a constant for<BR>
the SQL. Why did you do it this way? Why not just use a<BR>
Class::DBI::Plugin::set_sql that delegates to the class your plugged<BR>
into? hmmmm its a complile time thing isn't it...<BR>
<BR>
Or maybe an init_plugin method. Could also be usefull if the plugin wants<B=
R>
to add class data, TEMP columns etc.<BR>
e.g.<BR>
<BR>
&nbsp;sub init_plugin {<BR>
&nbsp;&nbsp;&nbsp;&nbsp; my $class =3D shift;&nbsp; # Class your plugged in=
to<BR>
&nbsp;&nbsp;&nbsp;&nbsp; $class-&gt;set_sql( count_search_where =3D&gt; &qu=
ot;...&quot; );<BR>
&nbsp;&nbsp;&nbsp;&nbsp; $class-&gt;mk_classdata('_plugin_search_where_foo'=
);<BR>
&nbsp;}<BR>
<BR>
(Apologies if this was covered in the 'abstract search count' thread)<BR>
<BR>
mark<BR>
<BR>
<BR>
</FONT>
</P>

<br>This email (and any attachments) is intended solely for the individual(=
s) to whom addressed. It may contain confidential and/or legally privileged=
 information. Any statement or opinions therein are not necessarily those o=
f ITN unless specifically stated. Any unauthorised use, disclosure or copyi=
ng is prohibited. If you have received this email in error, please notify t=
he sender and delete it from your system. Security and reliability of the e=
-mail and attachments are not guaranteed. You must take full responsibility=
 for virus checking.<br><br><br><br>Independent Television News Limited, <b=
r><br>Registered No. 548648 England,<br><br>VAT Reg. No: GB 756 2995 81, <b=
r><br>200 Gray's Inn Road, London WC1X 8XZ,<br><br>Telephone: 020 7833 3000=
=2E<br></BODY>
</HTML>
----=_NextPart_ST_17_20_57_Wednesday_June_30_2004_15476--

Class::DBI::Plugin
Jean-Christophe Zeus 15:38 on 30 Jun 2004

RE: Class::DBI::Plugin
Addison, Mark 16:17 on 30 Jun 2004

Re: Class::DBI::Plugin
Jean-Christophe Zeus 16:29 on 30 Jun 2004

Re: Class::DBI::Plugin
Jean-Christophe Zeus 07:40 on 02 Jul 2004

Re: Class::DBI::Plugin
Jean-Christophe Zeus 10:21 on 06 Jul 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52