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

Re: [cgiapp] remove duplicate callbacks? (was: Re: Yet another callback system proposal)


Cees Hek <suppressed> wrote:
> Somewhere along the line did we loose the ability to register a
> callback to the object?  In the latest patch, it looks like a call to
> $self->add_callback(...) will end up registering the callback in
> ref($self)  (or in otherwords, the class, not the object).
>
> This means you will not be able to register a one time callback in a
> persistent environment.

I hadn't considered the usefulness of one-time callbacks.  I've added
the feature and made a new tarball:

    http://occamstoothbrush.com/downloads/perl/CGI-Application-4.0_3-positionless-class-callbacks-patch3.tar.gz

Since we're running class-based callbacks in the order of more specific
(My::App) to less specific (CGI::Application), I made it so that
object-based callbacks run before class-based callbacks.

I also renamed the name of the storage variable/key from INSTALLED_HOOKS
to INSTALLED_CALLBACKS.  Dunno if that's an improvement or not.

> Here is an example where that might be useful.  Say you have a long
> running task that needs to be accomplished and you do not want the
> user to wait for a response.  To solve this problem, in your runmode
> you register a callback at the teardown stage, and you do the work in
> that callback.  The teardown stage runs after the HTML has been sent
> to the browser, so your callback can take as long as it wants without
> making the user wait (you could accomplish the same thing using a fork
> of course).

I've added this example to the docs.


Michael



-----------------------------------------------------------------------
Michael Graham <suppressed>

YAPC::NA 2005 Toronto - http://www.yapc.org/America/ - suppressed
-----------------------------------------------------------------------


---------------------------------------------------------------------
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.