Jifty::Continuation - Allows for basic continuation-based programming


Jifty::Continuation wraps up the information about a context that might have been expecting some sort of answer. It allows one to re-visit that context later by providing the continuation again. Continuations are stored on the user's session.

Continuations store a Jifty::Request object and the Jifty::Response object for the request. They can also store arbitrary code to be run when the continuation is called.

Continuations can also be arbitrarily nested. This means that returning from one continuation will drop you into the continuation that is one higher in the stack.

Continuations are generally created just before their request would take effect, activated by the presence of certain query parameters. The rest of the request is saved, its execution to be continued at a later time.

Continuations are run after any actions have run. When a continuation is run, it restores the request that it has saved away into it, and pulls into that request the values any return values that were specified when it was created. The continuations code block, if any, is then called, and then the filled-in request is then passed to the Jifty::Dispatcher.


Saves a continuation at the current state. Possible arguments in the PARAMHASH:


A Jifty::Continuation object, or the id of one. This represents the continuation that this continuation should return to when it is called. Defaults to the current continuation of the current Jifty::Request.


The Jifty::Request object to save away. Defaults to an empty Jifty::Request object.


The Jifty::Response object that will be loaded up when the continuation is run. Most of the time, the response isn't stored in the continuation, since the continuation was saved away before the actions got run. In the case when continuations are used to preserve state across a redirect, however, we tuck the Jifty::Response value of the previous request into the continuation as well. Defaults to an empty Jifty::Response object.


An optional subroutine reference to evaluate when the continuation is called.


Returns true if the continuation matches the current request's path, and it would return to its caller in this context. This can be used to ask "are we about to call a continuation?"


Call the continuation; this is generally done during request processing, after an actions have been run. Jifty::Request::Mapper-controlled values are filled into the stored request based on the current request and response. During the process, another continuation is created, with the filled-in results of the current actions included, and the browser is redirected to the proper path, with that continuation.


Returns from the continuation by pulling out the stored request, and setting that to be the active request. This shouldn't need to be called by hand -- use "return_from_continuation" in Jifty::Request, which ensures that all requirements are ment before it calls this.


Remove the continuation, and any continuations that would return to its scope, from the session.