[Tutor] Question on twisted.

Steve @ Home srobb@insightbb.com
Fri Mar 21 17:37:02 2003


I am attempting to look at twisted.  So far, it looks good.  Very, very,
good.  I have a problem with it though.  I ran the telnet app via the
'twistd' utility successfully.  As I read further there was a new example of
how to kick off the telnet server from within your preferred Python editor.

It reads as follows...

CHAPTER 2. THE BASICS 30
Python 1.5.2 (#0, Dec 27 2000, 13:59:38) [GCC 2.95.2 20000220 (Debian
GNU/Linux)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import sys
>>> sys.path.append('/twisted/Twisted')

The text - ( I installed Twisted in /twisted, so the place where my
'twisted' package directory is at is /twisted/Twisted/twisted
The text - ( (confusing, I know). For Python to nd the 'twisted' package,
it must have the directory containing the package in
The text - ( sys.path O which is why I added /twisted/Twisted.

>>> from twisted.internet import app, tcp
>>> from twisted.protocols import telnet
>>> application = app.Application('telnet')
>>> ts = telnet.ShellFactory()
>>> application.listenTCP(4040, ts)

The text - ( The above is basically what mktap telnet does. First we create
a new Twisted Application, we create a new
The text - ( telnet Shell Factory, and we tell the application to listen on
TCP port 4040 with the ShellFactory we've created.
The text - ( Now let's start the application. This causes all ports on the
application to start listening for incoming connections.
The text - ( This step is basically what the 'twistd' utility does.

>>> application.run()
twisted.protocols.telnet.ShellFactory starting on 4040

The text - ( You now have a functioning telnet server! You can connect with
your telnet program and work with it just the
The text - ( same as you did before. When you're done using the telnet
server, you can switch back to your python console and hit
The text - ( ctrl-C.

All of this was going along fine.  Then from the line
 ts = telnet.ShellFactory() , I get an error.
When I type this line in my interpreter I get the following...

ts = telnet.Shell.Factory()
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
AttributeError: 'module' object has no attribute 'Shell'

Up until then it was running through as documented.
I would like to get this working but can't quite figure
out what my trouble is.  The telnet server worked
perfect when I ran it from the utility.
Any suggestions or is anyone familiar with twisted?

OS Win9x
Python 2.2
Pythonwin win32all build 150
Twisted Win binaries (downloaded today)

Steve