[Twisted-Python] Basic Resource Tree question

Lusana Ali ali.lusana at gmail.com
Wed Mar 14 05:46:08 EDT 2012


Hi,

Im trying to setup just a very simple site using a Resource Tree (some
code below).
The problem I'm having is getting the root / to render. so when i go
to domain.com/ I get
"No Such Resource
No such child resource"

The child nodes {terms,profile} are rendering fine. So looking at the
resource tree and the main.py which holds the Main() Resource... how
can I fix this issue. I have already tried setting isLeaf = True in
Main() but that breaks terms and profile

Cheers

server.py
=======================================
# resource tree
root = Main()
root.putChild('terms', Terms())
root.putChild('profile', Profile())

site = server.Site(root)
reactor.listenTCP(6346, site)
reactor.run()

main.py
=======================================
class IndexPage(Resource):

    def __init__(self):
        print "created new index page"
        Resource.__init__(self)

    def render_GET(self, request):
        print "rendering get"
        return "<html>INDEX PAGE</html>"


class Main(Resource):

    def get_child(self, name, request):
        print "trying to get main"
        return IndexPage()



More information about the Twisted-Python mailing list