[Twisted-Python] another probably very simple question

this is actually the first time i've ever written a PB client in python. since my java client was calling the remote methods out of the awt/swing event thread, i never had to deal with this particular issue. while i'm waiting for the update to the java pb packages (*cough*itamar*cough* ;-) ), i figured it would be worthwhile to do up a text-based client in python. i know this relates to my poor understanding of deferreds, but i just can't figure out exactly how to go about doing what i want to do. i want to be able to continually prompt the user for a string that gets sent to a "parse" method on the remote object. i'm not exactly sure the right way to do this. do I just add a callback to the deferred returned by def main(): config = Options() if(config['login'] == None): config['login'] = getpass.getuser() passwd = getpass.getpass("%s@%s's password: " % (config['login'], config['host'])) client = TextClient() factory = pb.PBClientFactory() reactor.connectTCP(config['host'], int(config['port']), factory) defer = factory.login(credentials.UsernamePassword(config['login'], passwd), client) defer.addCallback(connected) reactor.run() def connected(perspective): command = raw_input("> "); defer = perspective.callRemote("parse", command)
participants (1)
-
Phil Christensen