[Twisted-Python] some demo scripts

Norbert Klamann Norbert.Klamann at klamann-software.de
Wed Mar 14 03:49:00 EST 2001


Hello all,
i started playing with twisted python 0.7.2  and it looks very interesting.
I tried to go along the 'philosophical tutorial to Twisted Python
' and created 4 little python-scripts on the way which initialize and use the 
minimalist telnet- and web-server. They run under windows nt and python 2 but 
should be portable.

Under Windows NT a start of the servers gives an attribute error because 
os.getgid() is nit implemented. I suppressed this message under NT :

line 975 sqq on \twisted\net.py could read :
                except:
                    if os.name == 'nt':
                        pass
                    else :
                        traceback.print_exc(file=sys.stdout)
                        print 'setuid/gid failed'

Enjoy

Norbert Klamann
Norbert Klamann
++
++ Klamann Software & Beratung GmbH
++ Franz-Marc-Str.174
++ D-50374 Erftstadt
++ Tel.: 02235 / 985272 ++ Fax: 02235 / 985273
++ Mobil : 0172 / 2797723
++ PGP Fingerprint :
++ 05CC  4362  E765  51F1  38D9  C43F  D907  B4D8  7873  3454

-------------- next part --------------
from twisted import threadable
threadable.init(0)
from cPickle import load 
selector = load(open('twistd_web.spl'))
from twisted import web
myTest = web.Test()
selector.servers[0].root.putChild('test',myTest)
selector.run()
from cPickle import dump
dump(selector)


-------------- next part --------------
from twisted import threadable
threadable.init(0)
from cPickle import load 
selector = load(open('twistd.spl'))
selector.run()
-------------- next part --------------
from twisted import threadable
threadable.init(0)
from twisted import net
selector = net.Selector()
from twisted import web
server = web.Server(8181, selector)
documentRoot = web.File('.')
server.setRoot(documentRoot)
server.startUp()
from cPickle import dump
dump(selector, open('twistd_web.spl','wb'))
-------------- next part --------------
from twisted import threadable
threadable.init(0)
from twisted import net
selector = net.Selector()
from twisted import telnet
server = telnet.Server(4040, selector)
from cPickle import dump
dump(selector, open('twistd.spl','wb'))


More information about the Twisted-Python mailing list