[Zope] Writing to browser from an external script?
kwhitesell at adelphia.net
Thu Oct 2 21:59:51 EDT 2003
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
to update the specific cell that has changed. (I've already gotten a
trivial prototype of this concept working.)
The way I was thinking about doing it is to spawn an external Python
script as a separate thread. So, first I send the page with the
contents at that moment. Without closing the connection, I issue a
blocking read on a pipe. When the process that updates the database
completes the transactions, it writes a message to the pipes of all
waiting scripts (there could be a dozen or so machines watching
this.) Each script then queries the tables for what has changed,
trivial prototype of this concept is working.)
Now, this was done from straight Python, using the CGIHTTPServer
module as a base. What I'd really like to do is integrate this with
Zope. In other words, I want the 'home' page to be a Zope object
(DTML template?) that can initiate this external thread. (I'm
assuming that it would have to be an external thread because of the
need to block on the pipe.)
First - the sanity check. Have I lost my mind wanting to do it this way?
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
So I guess my biggest question is - how can I send data directly to
the browser from an external script? (Can I pass the connection
object to that script?) Failing that, is there a way that I can
create a DTML template to iteratively call an external script, until
the script returns some magic value?
As you can see, I'm no expert at Zope, but I'm not one to shy away
from doing my own research, either. I'm not asking anyone to do this
for me, but a quick pointer as to what I should be reading about
would be most appreciated.
Oh, and once this is done, would anyone else be interested in seeing
this? I don't mind sharing at all. (Just don't laugh...)
Thanks in advance,
More information about the Zope