def queried(rows): if len(rows) < 1: result_d.callback(False) return if len(rows) > 1: while len(rows) > 0: row = rows.pop(0) if row[1] == 'rw': # db_user_type is 'rw', then break, we have the best account type break else: row = rows[0] # now row is the best account db_user, db_user_type, db_password_encrypted = row db_pass = decrypt(db_password_encrypted, box_pass) result_d.callback((db_user, db_pass)) return
def query_cb(rows): if len(rows) < 1: return_d.callback(None) return row = rows[0] token_id, username, password_encrypted, boxid, appid, origin, clientip, server_id, expired = row if expired < 0: # token is expired, delete it and return None query = "DELETE FROM tbl_tokens WHERE token_id = %s" params = [tid] conn.runOperation(query, params).addCallbacks(lambda empty: return_d.callback(None), return_d.errback) return # decrypt password password = decrypt(password_encrypted, self.db_pass) token = (username, password, boxid, appid, origin, clientip, server_id) return_d.callback(token)