Rhesa Rozendaal wrote:
> Mark Stosberg wrote:
> 
>> On 2005-06-16, Rhesa Rozendaal <[EMAIL PROTECTED]> wrote:
>>

> Let me see if I understand the process:
> - Plugin gets 'use'd;
>   - PLugin calls new_hook('html_tidy');
>   - Plugin calls add_callback('html_tidy', sub{ ... } );
> - at some point in user code, add a call to call_hook('html_tidy');
> 
> That doesn't look so bad, come to think of it! This would allow me to
> create two new hooks: fixup_html and validate_html. You would
> call_hook('validate') in your postrun, while I would call the fixup
> variety. That's a nice compromise!

I may be in the minority, but this actually sorta bothers me. I believe
the goal of the plugin system should be to create something flexible
enough that plugin authors can create something that is as transparent
to the users as possible. The ideal would be that the user doesn't have
to call any methods themselves unless they are setting some config params.

If the user has to decide when something gets run, why do we have
callbacks? Is there really any difference than just exporting a method.
Or in other words, is this:

  $self->new_hook('html_tidy');
  $self->add_callback('html_tidy, \&html_tidy);
  # more code, probably in another class...
  $self->call_hook('html_tidy', $output);

any better than

  $self->html_tidy($output);

Just so that I'm not misunderstood, I don't like either approach. Maybe
we should have the before_hook/after_hook hooks? So call_hook() would
execute the before_hook(), hook() and after_hook(). And these
before/after hooks would act just like normal hooks.

Or if we look at it another way...

Just document that the tidying happens in postrun and if the user has a
cgiapp_postrun method, it will be run after the tidying. Then encourage
the user to move their code from the postrun into a sub they add to the
postrun call back.


> I think it's best to keep the params to 'use' for real imports or stuff
> that really needs to happen at install time.

I agree for the most part. import() is for importing... not classs
initialization. And the param() method of C::A works well for passing
around plugin config data too.

-- 
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to