[Twisted-web] Setting server.Site.protocol stops the site factory
resource class from renderin
Steve doh
tfif at hotmail.com
Wed Feb 28 21:52:19 CST 2007
I have the code below that works fine. If I uncomment the 3rd to last line
so that the site.protocol uses the ServerProtocol class, then the
render_GET() method does not get called and the browser waits for a
response. I understand why this is happening but don't know how to fix it. I
need to override the connectionMade() method for the site factory inorder to
verify the connection. Can someone explain how I override connectionMade()
correctly? Any help appreciated. Cheers Steve
import os, sys
from twisted.web import http, static, server, resource
from twisted.internet.protocol import Protocol
from twisted.internet import reactor
class Simple(resource.Resource):
def render_GET(self, request):
sess = request.getSession()
request.write("<html>")
request.write("Hi there")
request.write("</html>")
request.finish()
return server.NOT_DONE_YET
class ServerProtocol(Protocol):
def connectionMade(self):
print "[connectionMade] entering function....."
os.chdir('D:\\web')
root = Simple()
root.putChild('index.html', Simple())
site = server.Site(root)
#site.protocol = ServerProtocol
reactor.listenTCP(80, site)
reactor.run()
_________________________________________________________________
Shop til you drop at XtraMSN Shopping http://shopping.xtramsn.co.nz/home/
More information about the Twisted-web
mailing list