Hi,

I am using WWW::Mechanize/LWP and some of their subclasses now for
several things and I see an architectural problem I will be facing in
some future:

For downstream developers (and for me) I need to offer a facility
to choose a user agent which supports a number of features:

  - local caching

  - specialized cookie handling for specific web sites

  - scripting (controlling the user agent via a dedicate language
    and not via Perl method calls to WWW::Mechanize).

  - triggering of application specific code at particular events
    (page loaded, link selection, page unload)

  - maybe optional JavaScript/DOM coverage later

Now much of this functionality is already there (I have implemented
scripting recently), but somehow spread over several packages in
incompatible ways. But for a downstream developer it is not possible
to say something like this:

  my $ua = new LWP::UserAgent::Pluggable;

  $ua->add_plugin (new LWP::UserAgent::Plugins::Cache (size => '4M'));
  $ua->add_plugin (new LWP::UserAgent::Plugins::Scriptable (plan => ...));
  $ua->add_plugin (new LWP::UserAgent::Plugins::Hooks (
                      ('http://specialsite/page' => sub { do something; }));

Does this make sense?

Sorry, if that has been discussed before.

\rho

Reply via email to