From 25963c366b5b377186afe4e6d260efa979d0c875 Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Mon, 3 Nov 2008 21:13:37 +0600 Subject: fixed twisted examples to use the updated twisteds.basic api --- examples/twisted_basic_client.py | 4 ++-- examples/twisted_basic_server.py | 2 +- examples/twisted_xcap_proxy.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'examples') diff --git a/examples/twisted_basic_client.py b/examples/twisted_basic_client.py index f5282df..948c214 100644 --- a/examples/twisted_basic_client.py +++ b/examples/twisted_basic_client.py @@ -1,7 +1,7 @@ from eventlet.twisteds import basic -conn = basic.connectTCP(basic.line_only_receiver, 'www.google.com', 80) -conn.send('GET / HTTP/1.0\r\n\r\n') +conn = basic.connectTCP('www.google.com', 80, buffer_class=basic.line_only_receiver) +conn.write('GET / HTTP/1.0\r\n\r\n') for line in conn: print line diff --git a/examples/twisted_basic_server.py b/examples/twisted_basic_server.py index 6af8b7e..3b32e79 100644 --- a/examples/twisted_basic_server.py +++ b/examples/twisted_basic_server.py @@ -24,6 +24,6 @@ class Chat: self.participants.remove(conn) chat = Chat() -basic.listenTCP(basic.line_only_receiver, chat.handler, 8007) +basic.listenTCP(8007, chat.handler, 8007, buffer_class=basic.line_only_receiver) from twisted.internet import reactor reactor.run() diff --git a/examples/twisted_xcap_proxy.py b/examples/twisted_xcap_proxy.py index 729dacc..a1475e0 100644 --- a/examples/twisted_xcap_proxy.py +++ b/examples/twisted_xcap_proxy.py @@ -4,7 +4,7 @@ from twisted.protocols import basic from xcaplib.green import XCAPClient -from eventlet.twisteds.util import callInGreenThread +from eventlet.twisteds.util import deferToGreenThread from eventlet.twisteds import join_reactor class LineOnlyReceiver(basic.LineOnlyReceiver): @@ -15,7 +15,7 @@ class LineOnlyReceiver(basic.LineOnlyReceiver): return app, context, node = (line + ' ').split(' ', 3) context = {'u' : 'users', 'g': 'global'}.get(context, context) - d = callInGreenThread(client._get, app, node, globaltree=context=='global') + d = deferToGreenThread(client._get, app, node, globaltree=context=='global') def callback(result): self.transport.write(str(result)) def errback(error): -- cgit v1.2.1