[Twisted-Python] LivePage Hello World

Eric Holm twisted at eholm.com
Wed May 21 21:53:23 EDT 2003

I'm trying to get a simple LivePage script going, 
and no luck so far.  I started with the example on 
howto/livepage.html, and added enough bits to get 
it to run (the only surprise was that Foo.setUp() 
needs a 3rd, unused argument), and I've attached 
it at the end of this mail.

When I view the source in the browser, there's 
a bunch of Flash stuff at the bottom (so *that's*
how "Javascript opens Socket to server" works...), 
but when fooHappened() runs, I get a

CACHING [<twisted.web.woven.utils.Script instance at 0x00F3F300>]

message.  The corresponding comment in utils.py 
talks about a conduit not being connected yet, 
but I've no idea how to initiate a connection. 
Anybody have any idea what I'm missing?

I'm using 1.0.5, python 2.2, Win2k.



from twisted.web.woven import page, interfaces
from twisted.internet import reactor

class Foo( page.LivePage ):
    template = ('<html><body>'
                'Nothing here!<span view="webConduitGlue" />'
    def setUp(self, request, document):
        currentPage = request.getSession(interfaces.IWovenLivePage)
        print "setUp: ", currentPage
        reactor.callLater( 5, fooHappened, currentPage )

def fooHappened( currentPage ):
    print "Foo!", currentPage
    currentPage.sendScript("alert('hello, world!')")

resource = Foo()

More information about the Twisted-Python mailing list