[Twisted-web] Run nevow site and xmlrpc server on the same port
Remi Cool
mailinglists at smartology.nl
Fri May 26 04:09:23 CDT 2006
Is it possible to run a nevow site and xmlrpc server on the same port?
If so ... how
I currently have the following code:
class nevowResource(rend.Page):
addSlash = True
def __init__(self, service):
rend.Page.__init__(self)
self.service = service
self.putChild('RPC2', protocols.xmlrpc(self.service))
rt = static.File("../frontend/nevow")
rt.ignoreExt(".rpy")
rt.processors = {'.rpy': script.ResourceScript}
rt.indexNames.append('index.rpy')
self.putChild('nevow', rt)
self.putChild('php', proxy.ReverseProxyResource('localhost', 80,
'/oldcode/'))
def locateChild(self, ctx, segments):
""""""
if segments[0] == '':
# If the server is looking for the root page segments will
be ('',)
# then renderHTTP will be called on self
return self.renderHTTP(self), ()
elif segments[0] in ctx.tag.children.keys():
return ctx.tag.children[segments[0]], segments[1:]
else:
return None, ()
def renderHTTP(self, ctx):
""""""
print 'render HTTP CTX:', dir(ctx)
if self == ctx:
return ctx.render_string()
return ctx.tag
application = service.Application('APP', uid=1000, gid=1000)
s = myService()
serviceCollection = service.IServiceCollection(application)
internet.TCPServer(8001,
appserver.NevowSite(s)).setServiceParent(serviceCollection)
With this solution, XMLRPC seems not to be working ... and on every page
request, the xmlrpc code is imported.
My service needs to be available/accessable from both the nevow site and
the XMLPC server.
What is the best way to implement this?
- Remi -
More information about the Twisted-web
mailing list