Bug 5243 - need a way to specify plugin call order
Summary: need a way to specify plugin call order
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Libraries (show other bugs)
Version: SVN Trunk (Latest Devel Version)
Hardware: Other other
: P5 minor
Target Milestone: 3.2.0
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-14 12:31 UTC by Justin Mason
Modified: 2006-12-15 09:00 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status

Note You need to log in before you can comment on or make changes to this bug.
Description Justin Mason 2006-12-14 12:31:20 UTC
Right now, if plugin A wishes to ensure that its finish_parsing_end method
(for example) is called before plugin B's, there's no way to do that.
We should provide a way.

I'm not sure how, exactly, but first glance suggests something like this:


  sub new { ... boilerplate ...
    $self->register_method_priority('finish_parsing_end', 200);
  }

in other words an API on the Plugin.pm object allowing a plugin implementation
to specify priority values at construction time.  there may be a better
way, of course.
Comment 1 Justin Mason 2006-12-14 12:32:06 UTC
I'm thinking about doing this for 3.2.0 since it's pretty important
for pluginability...
Comment 2 Michael Parker 2006-12-14 13:09:26 UTC
I hate to piggyback, but while you're in that part of the code how about adding
an option to the call plugin method that says some plugin MUST run and if not die.

That way we can force at least one plugin to implement a hook.  There might be
another bug opened for this already.
Comment 3 Justin Mason 2006-12-15 08:04:03 UTC
: jm 116...; svn commit -m "bug 5243: add Plugin::register_method_priority()
API, allowing plugins to control the relative ordering of plugin callbacks
relative to other plugins' implementations" lib/Mail/SpamAssassin/Plugin.pm
lib/Mail/SpamAssassin/PluginHandler.pm t/data/testplugin2.pm
t/plugin_priorities.t MANIFEST
Sending        MANIFEST
Sending        lib/Mail/SpamAssassin/Plugin.pm
Sending        lib/Mail/SpamAssassin/PluginHandler.pm
Adding         t/data/testplugin2.pm
Adding         t/plugin_priorities.t
Transmitting file data .....
Committed revision 487586.


let's see about the other request ;)
Comment 4 Justin Mason 2006-12-15 08:17:46 UTC
Michael: it looks like that can be done without adding a new API as follows.
instead of:

  $self->{main}->call_plugins ("check_main", { permsgstatus => $self }, required
=> 1); [or whatever]

use:

  if (!$self->{main}->have_plugin("check_main")) {
    die "no implementation found for 'check_main'!";
  }
  $self->{main}->call_plugins ("check_main", { permsgstatus => $self });


have_plugin() already exists.  I think I prefer the latter anyway, since it
allows the caller to decide what action to take if 'check_main' is unimplemented
by any plugin.

given that, I'll mark this as FIXED; reopen if you'd prefer to see a new API
instead.
Comment 5 Michael Parker 2006-12-15 09:00:48 UTC
Nah, that works for me, thanks.