[Twisted-Python] conroller.Controller.handle() returning a Deferred

Dave Thorne Dave at centralmanclc.com
Sun Oct 19 11:44:39 EDT 2003

I've been attempting to use the IRC channel to ask this question, but to no
avail. Maybe I'm not using the IRC client correctly, who knows.

However, I have a problem in a woven application whereby my Controller
object has a handle() method that returns a deferred (from an adbapi query)
on which I have set a callback to do something with the query data.

I assumed that my set callback would be executed before the callback that is
(presumably) set by woven to deal with the deferred's completion. Indeed,
with some print statements as debug tools I see that my callback really is
being executed, but as soon as the "checkMatch" callback returns the page

It is no doubt an easy problem to fix, but any help would be greatly
appreciated! I've placed the code for the controller below...



My Code:

class PreferencesController(controller.Controller):

   def handle(self, request):
      theApp = app.theApplication

      def checkMatch(results):
         #Do Stuff
         #Return: nothing, None, results?

      uname = "myusername"
      query = "SELECT * FROM people WHERE username = '%s'" % (uname)
      return theApp.dbpool.runQuery(query).addCallback(checkMatch)


More information about the Twisted-Python mailing list