[Twisted-Python] Deferred problem
vlupien at drummonddesigns.com
Tue Oct 28 09:28:52 EST 2003
I'm trying to construct a new class for authentification by a database.
I used the class FilePasswordDB in checkers to build my own class
I think my logic is alright but I get an Deferred error.
I tested my query in an other page and I know that's working fine.
The problem is that I don't know how I can make my program wait for the
result of my query (the query is very short).
I tried to use defer.succeed but it doesn't seem to work.
Here's my code that I'm working on:
__implements__ = (ICredentialsChecker,)
def __init__(self, dbpool):
self.dbpool = dbpool
self.credentialInterfaces = (credentials.IUsernamePassword,)
def _cbPasswordMatch(self, matched, username):
def getUser(self, username):
sql = """SELECT * FROM users WHERE name='%s'""" %username
results = self.dbpool.runQuery(sql) ## the deferred result
if results is not None:
return results, results
# same code as FilePasswordDB
def requestAvatarId(self, c):
u, p = self.getUser(c.username)
h = self.hash(c.username, c.password, p)
if h == p:
return defer.maybeDeferred(c.checkPassword, p
and here's the function where a call DatabaseAuthentification:
dbpool = database.DataBase().getConnection()
THE ERROR I GET:
237 in getUser
235 results = self.dbpool.runQuery(sql)
236 if results is not None:
237 return results, results
238 raise KeyError(username)
<twisted.cred.checkers.DatabaseIdentification instance at 0x007C4AA0>
<Deferred at 0xfe6af0>
'"SELECT * FROM users WHERE name='vicky'
exceptions.AttributeError: Deferred instance has no attribute
I've been working for a long time on this problem, help would be really
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python