[Twisted-web] livepage breaks after reload

noema mailinglists at shechen.at
Wed Jan 26 11:29:45 MST 2005


> You're locate child should look something more like ...
> 
> def locateChild(self, context, segments):
> 
>     # Do whatever you need to do here, probably returning
>     # a resource and the remaining segments.
> 
>     # I don't know what it is so let Page (my subclass) try.
>     return rend.Page.locateChild(self, context, segments)


I am not sure I fully understand what you mean. Am I not exactly doing 
what you are suggesting?!  I return a resource and the remaining 
segments. Just that in my case the resource is the current resource 
itself and the remaining segments are empty. (to make any child valid 
and be handled by MyPage (which it does just not with livepage support))

 > return rend.Page.locateChild(self, context, segments)

Isn't this returned/called anyways if I wouldn't overwrite the inherited 
locateChild methode.



>>What follows is some code that illustrates exactly that. Javascript 
>>events come perfectly through until I uncommend the localChild methode.
>>
>>#noema
>>
>>
>>
>>#################### START OF .TAC FILE ########################
>>
>>import random
>>from twisted.application import service, internet
>>from nevow import loaders, rend, tags, livepage, url
>>
>>
>>class MyPage(rend.Page):
>>     addSlash = True
>>
>>     #def locateChild(self, context, segments):
>>     #    #store the rest of the url for any kind of manual processing
>>     #    self.postpath = segments
>>     #    return self, ()
>>
>>     def onLinkAction(self, client):
>>         client.set('atag',
>>             random.choice(('one', 'two', 'three', 'four', 'five')))
>>
>>     def render_link(self, context, data):
>>         return tags.a(onclick=livepage.handler(self.onLinkAction),
>>                     href=url.here, id="atag")['click!']
>>
>>
>>     def render_glue(self, context, data):
>>         return livepage.glue
>>
>>
>>     docFactory = loaders.stan(
>>     tags.html[
>>         tags.head[
>>             tags.title["mypage"],
>>           ],
>>         tags.body[
>>             tags.div[
>>                 render_link
>>             ],
>>             tags.span(render=render_glue)
>>         ]
>>     ])
>>
>>
>>
>>application = service.Application('mypage')
>>internet.TCPServer(8080, livepage.LiveSite(MyPage()))\
>>     .setServiceParent(application)
>>
>>
>>#################### END OF .TAC FILE ##########################




More information about the Twisted-web mailing list