[Twisted-Python] Deferred problem
vlupien at drummonddesigns.com
Thu Nov 6 09:26:00 EST 2003
I know that I'd already post a message about deferred but I think I
haven't understand very well.
I have a function that is suppose to return a new dictionnary but it
returns a deferred.
templateFile = "main.html"
def initialize(self, dbpool=None):
self.dbpool = dbpool
def setUp(self, request, *args):
var = self.initPermissions(request) #var is suppose to get
the new list
def wmfactory_welcome(self, request):
return "Bienvenue, %s" %
def initPermissions(self, request): #create and return the
results of a sql query
group = request.getComponent(myguard.Authenticated).group
listGroup = group.split(',')
sql = "select permission from permissions where 1"
for item in listGroup:
sql += " or permissions.group='%s'" % item.lstrip()
theDeferred = self.dbpool.runQueryDict(sql)
return theDeferred.addCallback(self.makeDict) # suppose
to call makeDict when the results has arrived
def makeDict(self, results):
# when I print what is in results, I can see all the data
from the sql query
listPermissions = 
for item in results:
return listPermissions # return the new list
but the function setUp receive a deferred
I've put some comments in the code to help you understand what I want.
The big problem is that var receive a deferred and not the new list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python