I am _so_ busy.

package CBI::callbacks;

sub import{
    my $caller = caller();
    while(my($name,$thingy) = each %{"${caller}::"}){
        $name =~ /hook_(.+)/ or next;
        ...
    };
};




On 11/3/05, Tim Bunce <[EMAIL PROTECTED]> wrote:
> Are you volunteering?
>
> Tim.
>
> On Thu, Nov 03, 2005 at 01:24:21PM -0600, David Nicol wrote:
> > > "'connect.cached.new' => [\&pre, \&post]" syntax so that I could do
> >
> > If I understand correctly, the QPSMTPD people have just implemented
> > self-registering
> > callbacks in modules by standardizing the names of the callbacks and
> > letting package
> > introspection find them all.  The names are hook_* where * is one of
> > the times that
> > there is a hook for.
> >
> > Using that naming convention, a module would register it callback with the 
> > DBI
> > framework by merely having a function called something like
> >
> >    sub hook_connect_cached_new_pre{ ... }
> >
> > Perhaps the import function invoked by
> >
> >    use DBI::callback_hooks;
> >
> > could inspect the functions defined in its caller()'s package and
> > register what it
> > finds there with the calling-back mechanism.
> >
> > Just an idea -- I do not know if this approach would be better or
> > worse than what
> > is currently being done, or even if it is the same as what is
> > currently being done --
> > but in my opinion having multiple levels of naming
> >
> > > "'connect.cached.new' => [\&pre, \&post]"
> >
> > is going to be a hassle compared with a single level of naming that
> > gets as detailed as it needs.
> >
> >      connect_cached_new_pre  => \&pre,
> >      connect_cached_new_post => \&post;
> >
> > In the proposal at the top of this e-mail, presuming you have the pre and 
> > post
> > subs already written and don't want to touch them, the registration of them
> > could be implied with something like
> >
> >     INIT{
> >      *DBIhook_connect_cached_new_pre  = \&pre;
> >      *DBIhook_connect_cached_new_post = \&post;
> >     }
> >
> > if you don't want to just change their names.
>


--
David L Nicol
"Green blanket" -- Aurora

Reply via email to