Re: [Twisted-web] livepage breaks after reload
In weever (http://vercingetorix.dyndns.org:20080) I use liveevil with nevow from svn and it only breaks with safari.
Your app seems to work on my browsers
I think you are probably using an old version of nevow or something like that.
I just svn'd nevow the other day and to make sure I checked out the most current version again today -> the problem persists.
otherwise you are probably doing something wrong with the code but it's hard to tell without any code.
OK ... I boiled down my code to the bare minimum (originally it is derived from the chatola app) and as i suspected the problem is still reproducable. The following is a .tac file which I start with "twistd -noy <filename>". It starts a server with one page that has two livepage handlers. One of them is called when the page loads another one when you click the link. Everything works fine until I reload the page and/or add some locateChild action. More constructive thoughts appreciated. _noema #################### START OF .TAC FILE ######################## import random from twisted.cred import portal, checkers, credentials from twisted.application import service, internet from nevow import inevow, loaders, rend, tags from nevow import livepage, guard, url, appserver class MyPageRealm: __implements__ = portal.IRealm def __init__(self): self.clients = [] self.topic = "test1" def requestAvatar(self, avatarId, mind, *interfaces): if inevow.IResource in interfaces: if avatarId is checkers.ANONYMOUS: mind.userId = random.choice(('one', 'two', 'three')) def onSessionExpire(): self.userLeft(mind) return (inevow.IResource, MyPage([self, mind]), onSessionExpire) raise NotImplementedError("Can't support that interface.") def userJoined(self, client): if client in self.clients: self.userLeft(client) self.clients.append(client) def userLeft(self, client): self.clients.remove(client) class MyPage(rend.Page): def __init__(self, data): rend.Page.__init__(self, data) self.realm = data[0] self.client = data[1] def render_body(self, ctx, data): self.realm.userJoined(self.client) self.client.set('sometext', tags.h1['This is from LivePage!']) session = inevow.ISession(ctx) def unload(client): session.expire() return ctx.tag(onunload=livepage.handler(unload)) 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(render=render_body)[ tags.div(id='sometext')['to be filled by livepage'], tags.div[ render_link ], tags.span(render=render_glue) ] ]) realm = MyPageRealm() portal = portal.Portal(realm) portal.registerChecker(checkers.AllowAnonymousAccess(), credentials.IAnonymous) site = appserver.NevowSite( guard.SessionWrapper(portal, mindFactory=livepage.LiveEvil)) application = service.Application("mypage") internet.TCPServer(8080, site).setServiceParent(application) #################### END OF .TAC FILE ##########################
participants (1)
-
noema