thanks,all. I have <span>resolved it by twisted.web .xmprpc</span><br><br><div class="gmail_quote">On Fri, Mar 6, 2009 at 7:44 PM, Burus <span dir="ltr">&lt;<a href="mailto:eburus@gmail.com">eburus@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">You can try starting reactor. in the settings.py file, and use twisted   pb calls in the fjango views.<div><div></div>
<div class="h5"><br><br><div class="gmail_quote">On Fri, Mar 6, 2009 at 2:33 PM, Phil Mayers <span dir="ltr">&lt;<a href="mailto:p.mayers@imperial.ac.uk" target="_blank">p.mayers@imperial.ac.uk</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><div>Boern wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
hi,all:<br>
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.<br>
example:<br>
<br>
the remote service code :<br>
<br>
class Echoer(pb.Root):<br>
    def remote_echo(self, task):<br>
              print &#39;echoing:&#39;, task<br>
                return task<br>
<br>
if __name__ == &#39;__main__&#39;:<br>
    reactor.listenTCP(8789, pb.PBServerFactory(Echoer()))<br>
    reactor.run()<br>
<br>
-------------------------------------------------------------------------------------------------------------<br>
and the djiango views.py code :<br>
<br>
       def register_task(requst):<br>
&quot;&quot;&quot;register the task&quot;&quot;&quot;<br>
        .................<br>
factory = pb.PBClientFactory()<br>
reactor.connectTCP(&quot;localhost&quot;, 8789, factory)<br>
d = factory.getRootObject()<br>
d.addCallback(lambda object: object.callRemote(&quot;echo&quot;, task))<br>
d.addCallback(lambda echo: &#39;server echoed: &#39;+echo[0]+str(echo[1]))<br>
d.addErrback(lambda reason: &#39;error: &#39;+str(reason.value))<br>
d.addCallback(util.println)<br>
d.addCallback(lambda _: reactor.stop())<br>
reactor.run()<br>
</blockquote>
<br></div>
That won&#39;t work. The reactor cannot be started more than once. It needs to be long-lived.<br>
<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</blockquote></div><br>
</div></div><br>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Boern Parx<br>