[Twisted-Python] two deferred_tutorial patches

The first catches a bit more of the output from deferred_ex3.py which makes a bit more sense: Index: doc/core/howto/tutorial/deferred_tutorial.xhtml =================================================================== --- doc/core/howto/tutorial/deferred_tutorial.xhtml (revision 12146) +++ doc/core/howto/tutorial/deferred_tutorial.xhtml (working copy) @@ -157,6 +157,9 @@ File "./deferred_ex2.py", line 35, in failAtHandlingResult raise RuntimeError, "whoops! we encountered an error" exceptions.RuntimeError: whoops! we encountered an error + +callback 3 + got result: okay, continue on </pre> <h2>addBoth: the deferred version of <em>finally</em></h2> Actually, now that I look at it ... the output in the text is just from the wrong program: Index: doc/core/howto/tutorial/deferred_tutorial.xhtml =================================================================== --- doc/core/howto/tutorial/deferred_tutorial.xhtml (revision 12146) +++ doc/core/howto/tutorial/deferred_tutorial.xhtml (working copy) @@ -147,16 +147,22 @@ <pre> callback 1 got result: success +callback 2 + got result: yay! handleResult was successful! about to raise exception errback we got an exception: Traceback (most recent call last): ---- <exception caught here> --- - File "/home/slyphon/Projects/Twisted/trunk/twisted/internet/defer.py", line -326, in _runCallbacks - self.result = callback(self.result, *args, **kw) - File "./deferred_ex2.py", line 35, in failAtHandlingResult + File "deferred_ex3.py", line 94, in ? + behindTheScenes("success") +--- <exception caught here> --- + File "deferred_ex3.py", line 57, in behindTheScenes + result = failAtHandlingResult(result) + File "deferred_ex3.py", line 34, in failAtHandlingResult raise RuntimeError, "whoops! we encountered an error" exceptions.RuntimeError: whoops! we encountered an error + +callback 3 + got result: okay, continue on </pre> <h2>addBoth: the deferred version of <em>finally</em></h2> And the second one makes the tutorial look right when loaded from the filesystem. I have a feeling I am supposed to start a webserver or process these files somehow, but this was easier for me... Index: doc/core/howto/tutorial/deferred_tutorial.xhtml =================================================================== --- doc/core/howto/tutorial/deferred_tutorial.xhtml (revision 12146) +++ doc/core/howto/tutorial/deferred_tutorial.xhtml (working copy) @@ -1,6 +1,7 @@ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <title>Deferreds are beautiful! (A Tutorial)</title> +<link type="text/css" rel="stylesheet" href="../stylesheet.css" /> </head> <body> @@ -27,7 +28,7 @@ First, a simple example so that we have something to talk about: -<a href="../listings/deferred/deferred_ex.py" class="py-listing"></a> +<a href="../listings/deferred/deferred_ex.py" class="py-listing">deferred_ex.py</a> <p>And the output: (since both methods in the example produce the same output, it will only be shown once.) </p> @@ -56,7 +57,7 @@ returned the deferred needs to alert the callback chain that an error has occurred.</p> -<a href="../listings/deferred/deferred_ex1a.py" class="py-listing"></a> +<a href="../listings/deferred/deferred_ex1a.py" class="py-listing">deferred_ex1a.py</a> <pre> errback @@ -80,7 +81,7 @@ <p>Now let's see what happens when <em>our callback</em> raises an exception</p> -<a href="../listings/deferred/deferred_ex1b.py" class="py-listing"></a> +<a href="../listings/deferred/deferred_ex1b.py" class="py-listing">deferred_ex1b.py</a> <p>And the output: (note, tracebacks will be edited slightly to conserve space)</p> @@ -112,7 +113,7 @@ errback in the chain. If the chain is started off with a failure, the first method to be called will be the first errback.</p> -<a href="../listings/deferred/deferred_ex2.py" class="py-listing"></a> +<a href="../listings/deferred/deferred_ex2.py" class="py-listing">deferred_ex2.py</a> <pre> callback 1 @@ -142,7 +143,7 @@ failure or raise an exception) the chain continues on with the next callback.</p> -<a href="../listings/deferred/deferred_ex3.py" class="py-listing"></a> +<a href="../listings/deferred/deferred_ex3.py" class="py-listing">deferred_ex3.py</a> <pre> callback 1 @@ -168,7 +169,7 @@ returning the value that it received to allow processing the chain to continue, but appearing transparent in terms of the result.</p> -<a href="../listings/deferred/deferred_ex4.py" class="py-listing"></a> +<a href="../listings/deferred/deferred_ex4.py" class="py-listing">deferred_ex4.py</a> <pre> callback 1 @@ -205,7 +206,7 @@ addCallback followed by an addErrback.</p> -<a href="../listings/deferred/deferred_ex5.py" class="py-listing"></a> +<a href="../listings/deferred/deferred_ex5.py" class="py-listing">deferred_ex5.py</a> <pre> callback 1 @@ -227,7 +228,7 @@ processing in response to the error, we would have used a passthru, and returned the failure we received, as we see in this next example: </p> -<a href="../listings/deferred/deferred_ex6.py" class="py-listing"></a> +<a href="../listings/deferred/deferred_ex6.py" class="py-listing">deferred_ex6.py</a> <pre> callback 1 @@ -258,7 +259,7 @@ beforehand and then executes it, the other executes the chain as it is being constructed. This is because deferreds are <em>stateful</em>. </p> -<a href="../listings/deferred/deferred_ex7.py" class="py-listing"></a> +<a href="../listings/deferred/deferred_ex7.py" class="py-listing">deferred_ex7.py</a> <pre> callback 1 @@ -309,7 +310,7 @@ processing chain will become the result that gets passed to the next callback of the primary deferreds processing chain </p> -<a href="../listings/deferred/deferred_ex8.py" class="py-listing"></a> +<a href="../listings/deferred/deferred_ex8.py" class="py-listing">deferred_ex8.py</a> <pre> callback 1 Thanks for your time. _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.com/
participants (2)
-
Jonathan Simms
-
Lee Harr