[Zope] Writing to browser from an external script?

Passin, Tom tpassin at mitretek.org
Fri Oct 3 16:31:09 EDT 2003


[ Ken Whitesell]

> Here's the situation - I have a database that needs to be monitored.
> By that I mean that I want to "watch" a certain table from a PC,
> with live updates made when the contents in the database changes.
> 
> The problem is that the HTML table being created is rather large, so
> I don't want to retransmit that every time. I want to leave the
> connection open, and just send a short javascript routine as needed
> to update the specific cell that has changed. (I've already gotten a
> trivial prototype of this concept working.)
> 
>...
> First - the sanity check. Have I lost my mind wanting to do 
> it this way?
> 

Yes :-)  You are just asking for trouble having a lot of processes with
blocks, possibly at the same time.

> The common alternative that I usually read about involves sending
> the command to the browser to auto-refresh periodically.
> Unfortunately, that means that the entire page would have to be
> retransmitted every time - and I really don't want to have to do
> that. It just seems very wasteful to me to have to transmit 1000
> times the amount of data necessary to just update (typically) 15-20
> bytes.
> 
> So I guess my biggest question is - how can I send data directly to
> the browser from an external script? 

Well, I would consider an auto-refresh in another frame (possibly an
iframe) or in a popup window.  When the auto-refresh loads, you can have
it send the updated data to the parent.  The parent can do with it
whatever it wants.  Of course, you need to use javascript to make this
work.  I would be happy with that, myself.

A more web-like approach would be to set up another resource - another
url - that the main page should keep checking to get new data from

Cheers,

Tom P




More information about the Zope mailing list