On 14/05/05 23:06 +0530, Joshua N Pritikin wrote:
> Kwiki 0.33 has a store method in Kwiki::Page like this:
> 
> sub store {
>     super or return;
>     $self->call_hooks('store');
> }
> 
> In Kwiki 0.38, this store method is gone and it seems like the store is
> handled by Spoon::ContentObject.  However, I don't see the call_hooks
> thing in Spoon::ContentObject.

Hi Joshua,

I took out the call_hooks because it was a woefully underpowered abstraction.
I replaced with an amazing abstraction called Spoon::Hooks that allows you to
add pre/post hook methods to any method in Kwiki.

There are several plugins that already make use of this facility. Use them as
examples. To get started, just do something like this:


    package KwikiEmailDiffThingy;
    use Kwiki::Plugin -Base;

    const class_id => 'kwiki_email_diff_thingy';

    sub register {
        my $r = shift;
        $r->add(hook => 'page:store', pre => 'my_hook_sub');
    }

    sub my_hook_sub {
        $self = $self->hub->kwiki_email_diff_thingy;
        my $hook = pop;
        ...
        # $hook->cancel; # if you want to stop the original call...
        ...
    }

I think you'll agree that Spoon::Hooks gives you the power you need.

Cheers, Brian

PS drop by #kwiki on irc.freenode.net if you need more help.

> What I want to do is change store_content to write to a temporary
> filename and then atomically rename it into place.  This also has the
> advantage of putting the new & old file on disk for a moment.  I'd like
> to run hooks during this moment so I can generate a diff and email it.
> 
> What do you say?
> 
> -- 
> If you are an American then support http://fairtax.org
>  (Permanently replace 50,000+ pages of tax law with about 200 pages.)


Reply via email to