I just committed the first (lightly tested) code for plugin wrapping.

This lets you write plugins that look like this:

(plugins/wrap)

sub register {
  my ($self, $qp, $wrap, @args) = @_;
  $self->wrap_plugin($wrap,@args);
}

sub mail_handler {
  my ($self) = @_;
  warn "WE ARE HERE\n";
  my $r = $self->{_wrap_mail_handler}->(@_);
  warn "RESULT is $r\n";
  return $r;
}

The line in config/plugins  looks like this:
    wrap plugins/rhsbl

(this particular one is a silly example of wrapping the mail_handler
function from rhsbl.. You could change $r if you wanted before
returning.)  This allows you to easily modify plugin functionality
without rewriting or cargo-culting the entire plugin.

I don't really like the $self->{_wrap_mail_handler} part, It would be
pretty easy to wrap that in a function in the Plugin class.  I'm just
not really sure what to name it.  (I almost said "call it").

I'm not 100% sure that the symbol table munging is the way we want to
go here, but it was the easiest way to do it without making lots of
other changes.

it might make more sense to just use inheritance.  (Matt/Ask,
feelings?)

Then we can do things like:

  @ISA = (@ISA,$parent_plugin);

That can be done at any time (go perl!) so it could be done in the
register method, it just feels slightly wrong.  It does make the
wrapping easier, because it will all be handled by perl's method
lookup stuff, although it doesn't solve the static method
("subroutine") problem.

-R (who has evil plans for this)

Reply via email to