[Twisted-web] how are solving the calls to the children in nevow?

Alberto Trujillo alberto.trujillo at ucd.ie
Thu Jul 7 07:07:24 MDT 2005


Hello:
I have been following this example 
"http://nevowexamples.adytum.us/childrenhtml/"to know how works the 
calls to the children with nevow, but still it's not enough clear for me.

I even add a new child in the childFactory and some print command to 
follow the way of the calls. Here I show you my modifications:

    def childFactory(self, ctx, name):
        print "NAME = " + name
        if name in ['1', '2', '3']:
            return ChildPage(name)
        elif name == 'one':
            return OneRoot()

    def locateChild(self, ctx, segments):
        child, remainingSegments = rend.Page.locateChild(self, ctx, 
segments)
        print "CHILD = " + str(child) + " SEGMENT = " + 
str(remainingSegments)
        if child:
            print "IN THE IF"
            return child, remainingSegments

        return ChildPage('/'.join(segments)), []

My question is why each time that I call to "one" it goes inside 
"locateChild" wheter "one" is place in "childFactory", here is a trace 
of my server.

2005/07/07 13:52 IST [HTTPChannel,0,127.0.0.1] NAME = one
2005/07/07 13:52 IST [HTTPChannel,0,127.0.0.1] CHILD = <one.OneRoot 
object at 0x40701eac> SEGMENT = ()
2005/07/07 13:52 IST [HTTPChannel,0,127.0.0.1] IN THE IF
2005/07/07 13:52 IST [HTTPChannel,0,127.0.0.1] 127.0.0.1 - - 
[07/Jul/2005:12:52:11 +0000] "GET /one?id=1 HTTP/1.1" 200 47 
"http://localhost:8080/" "Mozilla/5.0 (X11; U; Linux i686; en-US; 
rv:1.7.8) Gecko/20050517 Firefox/1.0.4 (Debian package 1.0.4-2)"
2005/07/07 13:52 IST [HTTPChannel,0,127.0.0.1] NAME = favicon.ico
2005/07/07 13:52 IST [HTTPChannel,0,127.0.0.1] CHILD = None SEGMENT = ()
2005/07/07 13:52 IST [HTTPChannel,0,127.0.0.1] 127.0.0.1 - - 
[07/Jul/2005:12:52:11 +0000] "GET /favicon.ico HTTP/1.1" 200 684 "-" 
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050517 
Firefox/1.0.4 (Debian package 1.0.4-2)

And when I return to the father, who call to childrenRoot class again, 
and what is favicon.ico?. I show you the results here.

2005/07/07 13:58 IST [HTTPChannel,1,127.0.0.1] NAME = favicon.ico
2005/07/07 13:58 IST [HTTPChannel,1,127.0.0.1] CHILD = None SEGMENT = ()
2005/07/07 13:58 IST [HTTPChannel,1,127.0.0.1] 127.0.0.1 - - 
[07/Jul/2005:12:58:34 +0000] "GET /favicon.ico HTTP/1.1" 200 684 "-" 
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050517 
Firefox/1.0.4 (Debian package 1.0.4-2)"

I would like to know as well if I must to implement all these methods 
each time that I'm working with children, and what is segments.

Sorry I know that are a lot of question, but I don't have access to the 
IRC channel and I couldn't understand the information in "inevow.IReource".

Thanks a lot



More information about the Twisted-web mailing list