The PEAK Developers' Center   TwistedPeak UserPreferences
 
HelpContents Search Diffs Info Edit Subscribe XML Print View
Version as of 2003-07-12 09:02:09

Clear message


1 Introduction

This is a first cut at combining the [WWW]PEAK and [WWW]Twisted frameworks. We've taken the echoserver example from the doc/examples directory in the Twisted distribution, and "PEAK-ified" the Echo protocol to be a PEAK component. This example also shows a trivial use of the PEAK executable ZConfig and .ini machinery.

2 Prerequisites

This example requires that you have the [WWW]PEAK and [WWW]Twisted frameworks available on your system. More specifically, I am using PEAK from cvs as of July 10th, 2003, and the 1.0.5 release of Twisted. Please make sure you have these on your system and working before proceeding. Additionally, this example was done on a Linux system. The shell scripts probably won't work on Windows unless you have [WWW]Cygwin installed. If someone wants to contribute some .bat files, that would be great. Once you've done this, you may need to edit one file: setup-path. This is used if you've installed Twisted or some other library in some non-standard path, and you need to add it to your PYTHONPATH. This file is commented and should be self explanitory.

3 The Example Files

Download the Echo Server example files Here: Upload new attachment "echoserver-example.tar.gz"

4 Running The Example

In ascending order of complexity, you can run the following scripts in the root directory:

1. run-tp This script will call the peak script (installed when you installed the peak distribution), and it in turn will call the twistedpeak.echoserver:?EchoRunner class. This will start an ?EchoServer listening on port 8090 which will just echo back what you send it. Once you've started this script, test it by running:

telnet localhost 8090 
2. run-tp2 This script will call the peak script (installed when you installed the peak distribution), and it in turn will call the twistedpeak.echoserver2:?Echo2Runner class. This will start an ?EchoServer listening on port 8091 which will just echo back what you send it, prepended with: you said: This example is slightly more complicated, as it uses PEAK's logging system to log what the client sends to it. Once you've started this script, test it by running:
telnet localhost 8091 
3. run-tp-schema This script kicks off quite a lot. First of all it will utilize the PEAK's ZConfig and .ini machinery. See files tp.zcfg, and tp.ini for more details. Essentially, the tp.ini defines the logging that the Echo2 server uses. By default, it will log all client connections to the file logs/echoserver.log. You can change it to log to stderr by editing the file (there are comments how to do this in the file). The tp.zcfg file is more complicated. You may want to familiarize yourself with the ZConfig machinery first. Here's a good [WWW]Start. If you go to the file tp.zcfg, you will see sections for ?EchoRunner and ?EchoRunner2. For ?EchoRunner, you can configure the port it listens on, and for ?EchoRunner2 you can configure the port it listens on, and the text it prepends to replies. You will also want to examine to files src/twistedpeak?/EchoSchema.xml, and src/twistedpeak/component.xml. These files define the configuration schema used in tp.zcfg. Don't worry if you find this confusing! I did too. Just read the ZConfig tutorial, read, and re-read the tp.zcfg and schema files until you see their connections. If you're still stuck, post to the list. Once you've started this script, test it by running:
telnet localhost 8080 
and:
telnet localhost 8081 

5 Thanks

Thanks to all the folks on the PEAK maillist and irc channel who helped me get up to speed on this. I hope some people find this useful.

--Joel Boehland


PythonPowered
EditText of this page (last modified 2003-07-12 09:02:09)
FindPage by browsing, title search , text search or an index
Or try one of these actions: AttachFile, DeletePage, LikePages, LocalSiteMap, SpellCheck