On Tue, Feb 22, 2005 at 09:12:00AM -0800, David Wheeler wrote:
> 
> >That's great. You've got it to the point were I can't ignore it any
> >more :-)  I'll apply it and finish it up.
> 
> Woo! That's what I was looking for! Time well spent, then. :-) I'll 
> have to look at the diff after you've done it to see what I missed.

It ended up a little different in that I don't use an extra element
in the struct but just hv_fetch "Callbacks" when needed.
So it's more like the way "Profile" is handled. I should have pointed
you in that direction rather than to the older CachedKids style.

Anyway, it's in now, with support for callbacks on *every* method
and *every* handle. So this does what you'd expect:

  $dbh->{Callbacks}->{ping} => sub { print "Called ping!\n"; return; };
  $dbh->ping;

The return; is because I've not decided how to interpret return values
so to avoid problems later I've mandated that callbacks must return nothing.

What's missing, roughly in order of importance...

0. Documentation.
1. callbacks are only passed the handle, not the other method args.
2. No support for post-call callbacks via
        $dbh->{Callbacks}->{prepare} => [ \&pre, \&post ]
3. The method name isn't available via a localized $_
4. Define interesting uses for the return values, if any.
5. A DBI::Callbacks module to provide an interface for managing
   callbacks, including a way to define callbacks to be applied
   to all future child statement handles (by using a post-prepare).

Any volunteers for any of those?

Tim.

p.s. There's no PurePerl support and I've no plans to add it anytime soon.

Reply via email to