[Twisted-web] LivePage erratic under IE 6.0

Garth T Kidd garthk at gmail.com
Sun May 22 19:17:14 MDT 2005


To see whether LivePage is the right foundation for a side-project,
I've written a rudimentary ping program that updates the client DOM.
Under FireFox, all works as expected. Under IE, it worked for text
pings (handled entirely in ping()) but not for numeric pings (handled
by the Blaster class). Then it stopped working at all. I'm most
puzzled.

Versions:

    nevow 0.4.1
    twisted 2.0.0
    python 2.3.5
    IE 6.0.2800.1106.xpsp2.040919-1003CO

Script: 

from nevow import loaders
from nevow import tags
from nevow import livepage
from nevow import appserver

from twisted.internet import reactor

class Blaster: 
    def __init__(self, client, tenths): 
        self.client = client
        self.tenths = tenths
        self.now = 0.0
    def __call__(self): 
        self.client.set('head', str(self.now))
        self.now = self.now + self.tenths/10.0
        if self.now < 10:
            reactor.callLater(self.tenths/10.0, self)
            
def ping(client, payload): 
    try: 
        Blaster(client, float(payload))()
    except ValueError: 
        client.set('head', payload)
        reactor.callLater(1, client.set, 'head', "Do it again!")

ping = livepage.handler(ping, 
            livepage.document.getElementById('payload').value)

class Twister(livepage.LivePage):
    addSlash = True
    
    docFactory = loaders.stan( 
        tags.html[
            tags.head[
                tags.directive('liveid'),
                tags.directive('liveglue') 
                ],
            tags.body[
                tags.h1(id='head') ["Twist me, baby!"],
                tags.div(id='pingform') [
                    tags.form(name='ping', onsubmit=ping) [
                        tags.input(name='payload', id='payload'), 
                        tags.button['Ping!']
                        ]
                    ]
                ]
            ]
        )

if __name__ == '__main__':
    reactor.listenTCP(7080, appserver.NevowSite(Twister()))
    reactor.run()



More information about the Twisted-web mailing list