[Twisted-Python] woven dynamic table cell updating (w/ LivePage)

Justin Johnson justinjohnson at fastmail.fm
Fri Oct 10 12:08:34 EDT 2003

I decided to use images to display the status, and then have a server
side event send javascript to the page to change the src attribute of the

I got the table displaying properly, and setup the following event
handler so that when I click a specific link, the server sends javascript
to the page to change the image src:

class MyEventHandler(input.Anything):
    def initialize(self):
        self.view.addEventHandler("onclick", self.onClick)
    def onClick(self, request, widget):
        currentPage = request.getSession(interfaces.IWovenLivePage)
        script = """
        document.images.task1_step1.src = "/images/S.gif" 
        print self, "CLICKED!!!"

I verified that the image has a name attribute set to task1_step1.  When
I click, the javascript is sent, but I get the following javascript

Error: 'document.images.task1_step1 is null or not an object

I tried using document.images[0].src instead, and got a similar error:

Error: 'document.images.0' is null or not an object

Do I have to do something goofy to reference things with javascript when
it is sent using LivePage?

Thanks again for answering my numerous questions.

On Fri, 10 Oct 2003 07:37:04 -0600, "Justin Johnson"
<justinjohnson at fastmail.fm> said:
> I have some code (attached ui.py) that creates a table displaying results
> of running tasks.  The rows are tasks and the columns are step numbers in
> that task.  I use this table when I make a bunch of requests into PB
> servers running on multiple machines.  As those tasks move forward, the
> PB server calls back into the client (which has a perspective_* method)
> to update the status of that task/step.  An 'I' appears for 'in
> progress', 'S' for 'success', and 'F' for 'failure'.  If there are
> failures, I display the details once the entire table is populated and
> all tasks are complete.
>       | 1 | 2 | 3 | 4 | 5 | status
> --------------------------------------
> task1 | S | S | S | S | S | success
> --------------------------------------
> task2 | S | S | I | I | I | in progress
> --------------------------------------
> task3 | S | S | I | I | I | in progress
> --------------------------------------
> task4 | S | S | I | I | I | in progress
> --------------------------------------
> task5 | I | I | I | I | I | in progress
> --------------------------------------
> In the console based version each time the PB server task calls back into
> the client to update the status, it also requests that the client
> redisplay the screen.  So the screen redraws quite often.  Does anyone
> know how I could do something similar with woven?  My thought was that
> this will require LivePage, but I'm not sure.  Anyone have any
> thoughts/suggestions?  I've attached (in widgets.py) my first attempt at
> porting the results table to woven.
> Thank you.
> -Justin
> P.S.
> To run the attached file, you'll need to get the following modules.
> WConio: http://newcenturycomputers.net/projects/wconio.html
>     Windows Console I/O
>     1.5 or later.
> anycons: http://newcenturycomputers.net/projects/anycons.html
>     Simple Universal Console I/O
>     1.1 or later.

More information about the Twisted-Python mailing list