[Twisted-Python] Nevow and twisted.enterprise and deferreds

Alexander May alex-news at comcast.net
Tue May 25 09:49:58 EDT 2004

I could have sworn that I tried that last night, but I guess I didn't since
it works.  Thanks.

Is there a way to have a different render method called in the error case?
If not, I can always conditionally branch in the render method.


-----Original Message-----
From: twisted-python-bounces at twistedmatrix.com
[mailto:twisted-python-bounces at twistedmatrix.com] On Behalf Of Christopher
Sent: Tuesday, May 25, 2004 5:27 AM
To: Twisted discussion stuff
Subject: Re: [Twisted-Python] Nevow and twisted.enterprise and deferreds

Alexander May wrote:
> I am using nevow and twisted enterprise and have a situation like this:
> dbPool = adbapi.ConnectionPool('myDB') ...
> class MyPage(rend.Page):
>     ...
>     def data_mydata(self, context, data):
>         return dbPool.runQuery("select * from table")

Add an errback to this Deferred that you're returning. 
d.addErrback(self._cbQueryError), and make that method return nevow data
that can be rendered.

>     def render_myrender(self, context, data):
>         ...
> Happily, and a bit unexpectedly, it worked and the page rendered
> My issue is if the sql statement fails for some reason the page 
> rendering just hangs.  Is there an endorsed way to capture the error 
> and render some html from it?  Right now I'd be happy to see the call 
> stack, as I often do when an exception occurs.

  Twisted | Christopher Armstrong: International Man of Twistery
   Radix  |          Release Manager,  Twisted Project
---------+           http://radix.twistedmatrix.com/

More information about the Twisted-Python mailing list