[Twisted-web] livepage breaks after reload

noema mailinglists at shechen.at
Wed Jan 26 08:37:00 MST 2005


Ahh this is killing me!
Part of the problem that I described earlier in this thread is that 
simply adding a locateChild stops javascript events from triggering the 
connected python function/methode.

I am trying to render the same page no matter what url (past the domain) 
  is given. This single page should render differently depending on the 
url, though. So in locateChild I store the url segments and return self 
and an empty segment tuple. This seems to work but, as I said, breaks 
the livepage functionality.

WHY is locateChild DOING thaaAAt????

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