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

Alexander May alex-news at comcast.net
Tue May 25 02:19:13 EDT 2004

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")

    def render_myrender(self, context, data):

Happily, and a bit unexpectedly, it worked and the page rendered correctly.

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.

I traced through the call stack and found this in renderer.py

def _error(failure):
    # FIXME: this should *definitely* do something better
    # doing this leaves the connection hanging, but it's better
    # than nothing.
    print "FAILURE !",failure 

It looks like the errback is just set to _error.  I don't know if there is a
way to work around this.  I attempted a few things with my own errbacks to
no avail.  I'm sure much of this is due to my less than perfect
understanding of deferreds, and my current bleary eyed state.

I could have sworn that I read something about defereds and nevow, but I
can't seem to find it anymore.

Any help is appreciated.


PS: I'm using nevow 0.1 and twisted 1.2.

More information about the Twisted-Python mailing list