[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] positional plugin ordering


Rhesa Rozendaal wrote:
> Michael Peters wrote:

>> Right now the order of execution for callbacks is based on the class
>> inheritance tree which in turn is controlled by the order the user
>> 'uses' the plugins. So, anything added to an existing callback would
>> always be run before the built in sub (ie, cgiapp_prerun, etc).
> 
> 
> Yes. In effect, all current callbacks are before_* triggers.

That is true.

>> I'm not proposing something really complicated, but just a simple
>> before/after mechanism. Besides the above, here is another use case...
> 
> 
> I think if the core would contain additional after_* hooks right after
> every cgiapp stage, we'd be almost there. They would run with the same
> arguments as the existing hooks.

This is true. After reading the above, and other comments you make below
this doesn't seem like that big of a change.


> I think we can achieve that to a great degree if we collectively agree
> on publishing our plugins' hook points. If we additionally promise to
> add hook points to our plugins as well, all plugins should be able to
> work together and play nice.
> In your use case, your plugins would also register a before_config, and
> a before_dbh and after_dbh.
> 
> So basically what I propose is:
> 1) add after_init, after_prerun, after_postrun, and after_teardown hooks
> to cgiapp
> 2) agree that plugins register before_foo and after_foo hooks around
> their own hooks

This makes a lot of sense to me. Although, as you pointed out, every
callback runs before the original. So, if a plugin defines a new
'config' hook, it should also add the appropriate callback. Then anyone
who adds after that will be run before.

So maybe if a plugin creates a new hook they would just need to also
create and call the after_* and not the before_*. But this isn't really
a big deal either way.

But this begs the question, if all plugins should register an after_
hook after any new hooks it creates, then can't this be done
automatically in call_hook()?

-- 
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.