[Checkins] SVN: zc.ngi/trunk/src/zc/ngi/ Added a simpler output formatter.

Jim Fulton jim at zope.com
Wed Oct 4 13:38:11 EDT 2006


Log message for revision 70537:
  Added a simpler output formatter.
  

Changed:
  U   zc.ngi/trunk/src/zc/ngi/README.txt
  U   zc.ngi/trunk/src/zc/ngi/testing.py

-=-
Modified: zc.ngi/trunk/src/zc/ngi/README.txt
===================================================================
--- zc.ngi/trunk/src/zc/ngi/README.txt	2006-10-04 17:33:05 UTC (rev 70536)
+++ zc.ngi/trunk/src/zc/ngi/README.txt	2006-10-04 17:38:10 UTC (rev 70537)
@@ -348,6 +348,18 @@
     .> lo hello hello hello hello hello hello hello hello
     .>  '
 
+Text output
+===========
+
+If the output from an application consists of short lines of text, a
+TextConnection can be used.  A TextConnection simply outputs it's data
+directly.
+
+    >>> connection = zc.ngi.testing.TextConnection()
+    >>> connection.write('hello\nworld\n')
+    hello
+    world
+
 END_OF_DATA
 ===========
 

Modified: zc.ngi/trunk/src/zc/ngi/testing.py
===================================================================
--- zc.ngi/trunk/src/zc/ngi/testing.py	2006-10-04 17:33:05 UTC (rev 70536)
+++ zc.ngi/trunk/src/zc/ngi/testing.py	2006-10-04 17:38:10 UTC (rev 70537)
@@ -91,6 +91,18 @@
             return self.close()
         self.peer.test_input(data)
 
+class TextPrintingHandler(PrintingHandler):
+
+    def handle_input(self, connection, data):
+        print data,
+
+class TextConnection(Connection):
+
+    control = None
+
+    def __init__(self, peer=None, handler=TextPrintingHandler):
+        Connection.__init__(self, peer, handler)
+
 _connectable = {}
 
 def connector(addr, handler):



More information about the Checkins mailing list