resource constructor called on every request
Hello, I don't know if this is a 'normal' twisted/nevow operation procedure, but my base resources' __init__ is called on every request. Since a putChild for XMLRPC is setup in this __init__ (which includes a lot of code), I'm worried about execess overhead. Is there a way to include the XMLRPC section in a way that it get's initialized only once? I need the XMLRPC functionality on the same port as the HTTP(S) for firewall reasons. Something else ... in locateChild -> if segments[0] == '': # If the server is looking for the root page segments will be ('',) # then renderHTTP will be called on self When I return self, () a max recursion error is the result ... what should I return here? -- CODE -- class httpResource(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("www") rt.ignoreExt(".rpy") rt.processors = {'.rpy': script.ResourceScript, '.php': phpScript} rt.indexNames.append('index.php') self.putChild('www', rt) 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 None, () elif segments[0] in ctx.tag.children.keys(): return ctx.tag.children[segments[0]], segments[1:] else: return None, () def renderHTTP(self, ctx): """""" if self == ctx: return "<html><body>renderHTTP: ROOT</body></html>" return ctx.tag components.registerAdapter(httpResource, IowwService, inevow.IResource)
Remi Cool wrote:
Something else ... in locateChild ->
if segments[0] == '': # If the server is looking for the root page segments will be ('',) # then renderHTTP will be called on self
When I return self, () a max recursion error is the result ... what should I return here?
When I return: self.renderHTTP(self), () ... it looks like it's going ok, is this the correct way? - Remi -
participants (1)
-
Remi Cool