~djfroofy/+junk/trialtimeouts-2675

« back to all changes in this revision

Viewing changes to doc/web/howto/web-in-60/interrupted.xhtml

  • Committer: exarkun
  • Date: 2010-09-18 15:36:46 UTC
  • Revision ID: svn-v4:bbbe8e31-12d6-0310-92fd-ac37d47ddeeb:trunk:30040
Merge sphinx-web60-4577

Author: jdb
Reviewer: exarkun
Fixes: #4577

Tweaks to the Lore markup in the Web documentation to make it
more amenable to conversion to Sphinx.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
         request.finish()
46
46
</pre>
47
47
 
48
 
<p>Before defining the render method, we're going to define an errback (an
49
 
errback being a callback that gets called when there's an error), though. This
50
 
will be the errback attached to the <code>Deferred</code> returned by
51
 
<code>Request.notifyFinish</code>. It will cancel the delayed call to
52
 
<code>_delayedRender</code>.</p>
 
48
<p>Before defining the render method, we're going to define an errback
 
49
(an errback being a callback that gets called when there's an error),
 
50
though. This will be the errback attached to the <code>Deferred</code>
 
51
returned by <code>Request.notifyFinish</code>. It will cancel the
 
52
delayed call to <code>_delayedRender</code>.</p>
53
53
 
54
54
<pre class="python">
55
55
def _responseFailed(self, err, call):
56
56
    call.cancel()
57
57
</pre>
58
58
 
59
 
<p>Finally, the render method will set up the delayed call just as it did
60
 
before, and return <code>NOT_DONE_YET</code> likewise. However, it will also use
61
 
<code>Request.notifyFinish</code> to make sure <code>_responseFailed</code> is
62
 
called if appropriate.</p>
 
59
<p>Finally, the render method will set up the delayed call just as it
 
60
did before, and return <code>NOT_DONE_YET</code> likewise. However, it
 
61
will also use <code>Request.notifyFinish</code> to make
 
62
sure <code>_responseFailed</code> is called if appropriate.</p>
63
63
 
64
64
<pre class="python">
65
65
def render_GET(self, request):
68
68
    return NOT_DONE_YET
69
69
</pre>
70
70
 
71
 
<p>Notice that since <code>_responseFailed</code> needs a reference to the
72
 
delayed call object in order to cancel it, we passed that object to
73
 
<code>addErrback</code>. Any additional arguments passed to
74
 
<code>addErrback</code> (or <code>addCallback</code>) will be passed along to
75
 
the errback after the <code class="API"
76
 
base="twisted.python.failure">Failure</code> instance which is always passed as
77
 
the first argument. Passing <code>call</code> here means it will be passed to
78
 
<code>_responseFailed</code>, where it is expected and required.</p>
 
71
<p>Notice that since <code>_responseFailed</code> needs a reference to
 
72
the delayed call object in order to cancel it, we passed that object
 
73
to <code>addErrback</code>. Any additional arguments passed
 
74
to <code>addErrback</code> (or <code>addCallback</code>) will be
 
75
passed along to the errback after the <code class="API"
 
76
base="twisted.python.failure">Failure</code> instance which is always
 
77
passed as the first argument. Passing <code>call</code> here means it
 
78
will be passed to <code>_responseFailed</code>, where it is expected
 
79
and required.</p>
79
80
 
80
81
<p>That covers almost all the code for this example. Here's the entire example
81
82
without interruptions, as an <a href="rpy-scripts.xhtml">rpy script</a>:</p>