[prev] [thread] [next] [Date index for 2004/06/30]
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> ><BR> > In the thread "abstract search count" I volunteered writing = an abstract<BR> > base class for cdbi plugins. The reason for this is to make writing<BR= > > plugins easier, i.e. no symbol table hackery and no (well, no too much= )<BR> > knowledge about the internals of Class::DBI.<BR> ><BR> > In the thread mentioned above, Stephen Quinney proposed using code<BR> > attributes to specify which methods of the plugin subclass should be<B= R> > "plugged" in the caller's package.<BR> ><BR> > My proposals are as follows:<BR> ><BR> > 1) Methods with the attribute "Plugged" are exported,<BR> ><BR> > 2) The optional constant SQL is used for setting SQL in the caller's<B= R> > package.<BR> ><BR> > Here is an example (abridged):<BR> ><BR> > package Class::DBI::Plugin::AbstractCount;<BR> ><BR> > use base 'Class::DBI::Plugin';<BR> > use constant SQL =3D> ( count_search_where =3D> $SQL );<BR> > sub count_search_where : Plugged<BR> > {<BR> > my $class =3D shift;<BR> > # ...<BR> > $class->sql_count_search_where( ... );<BR> > }<BR> ><BR> > I refactored the original version of this plugin (which didn't inherit= <BR> > from Class::DBI::Plugin), and that cleaned it up a lot.<BR> ><BR> > Of course there are lots of features which could be added, but I think= <BR> > it's already quite useful, so I will upload it to CPAN. Is it OK for<B= R> > 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> sub init_plugin {<BR> my $class =3D shift; # Class your plugged in= to<BR> $class->set_sql( count_search_where =3D> &qu= ot;..." );<BR> $class->mk_classdata('_plugin_search_where_foo'= );<BR> }<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
|
RE: Class::DBI::Plugin
|
Re: Class::DBI::Plugin
|
Re: Class::DBI::Plugin
|
Re: Class::DBI::Plugin
|
Generated at 11:34 on 01 Dec 2004 by mariachi v0.52