thanks,all. I have resolved it by twisted.web .xmprpc On Fri, Mar 6, 2009 at 7:44 PM, Burus <ebu...@gmail.com> wrote:
> You can try starting reactor. in the settings.py file, and use twisted pb > calls in the fjango views. > > > On Fri, Mar 6, 2009 at 2:33 PM, Phil Mayers <p.may...@imperial.ac.uk>wrote: > >> Boern wrote: >> >>> hi,all: >>> I developed a web app in diango and a remote service in twisted, and I >>> want to invoke the twisted remote method in django web. >>> example: >>> >>> the remote service code : >>> >>> class Echoer(pb.Root): >>> def remote_echo(self, task): >>> print 'echoing:', task >>> return task >>> >>> if __name__ == '__main__': >>> reactor.listenTCP(8789, pb.PBServerFactory(Echoer())) >>> reactor.run() >>> >>> >>> ------------------------------------------------------------------------------------------------------------- >>> and the djiango views.py code : >>> >>> def register_task(requst): >>> """register the task""" >>> ................. >>> factory = pb.PBClientFactory() >>> reactor.connectTCP("localhost", 8789, factory) >>> d = factory.getRootObject() >>> d.addCallback(lambda object: object.callRemote("echo", task)) >>> d.addCallback(lambda echo: 'server echoed: '+echo[0]+str(echo[1])) >>> d.addErrback(lambda reason: 'error: '+str(reason.value)) >>> d.addCallback(util.println) >>> d.addCallback(lambda _: reactor.stop()) >>> reactor.run() >>> >> >> That won't work. The reactor cannot be started more than once. It needs to >> be long-lived. >> >> >> _______________________________________________ >> Twisted-Python mailing list >> Twisted-Python@twistedmatrix.com >> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python >> > > > _______________________________________________ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > > -- Boern Parx
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python