469,323 Members | 1,610 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Python CGI - outputting to textarea

I have a long running python cgi which in the end returns a link to a
pdf file. While it runs it generates a log that uses stdout right into
the html. I use the sys.stdout.flush() to make this log output
relatively realtime.

The log, however, has grown too long. I wish to output it instead
into a textarea. I thought I could just use the textarea tags before
the output starts. This works, but my output is no longer "real time"
even with the flush (it waits till I close the textarea tag to display
it). Anyone know a method how I can make it write to the textarea as
it goes?

Thanks,

Mark
Jul 18 '05 #1
2 2391
On Mon, 11 Oct 2004 14:18:26 -0700, LarsenMTL wrote:
I have a long running python cgi which in the end returns a link to a
pdf file. While it runs it generates a log that uses stdout right into
the html. I use the sys.stdout.flush() to make this log output
relatively realtime.

The log, however, has grown too long. I wish to output it instead
into a textarea. I thought I could just use the textarea tags before
the output starts. This works, but my output is no longer "real time"
even with the flush (it waits till I close the textarea tag to display
it). Anyone know a method how I can make it write to the textarea as
it goes?


You're fighting HTTP and HTML, which just aren't designed for this sort of
thing. Even your "relatively realtime" former implementation is an
accident; at any time any browser could choose to do more buffering and
un-real-time your log.

You're not likely to get more out of the solution than you already have.
Either trim the log, or, if it is getting long because it has to do more
that takes more time, tell the user their request has been accepted, and
email them when it is done. This is a common solution to this problem.

If you want to get crazy, fire the process off somehow, and create a way
for it to give status reports, and use client-side Javascript, with
XMLHTTPRequest, to read off the status periodically. This can in theory be
made cross-browser but I have no idea how true that is.
Jul 18 '05 #2
la*****@yahoo.com (LarsenMTL) wrote in message news:<99**************************@posting.google. com>...
I have a long running python cgi which in the end returns a link to a
pdf file. While it runs it generates a log that uses stdout right into
the html. I use the sys.stdout.flush() to make this log output
relatively realtime.

The log, however, has grown too long. I wish to output it instead
into a textarea. I thought I could just use the textarea tags before
the output starts. This works, but my output is no longer "real time"
even with the flush (it waits till I close the textarea tag to display
it). Anyone know a method how I can make it write to the textarea as
it goes?

Thanks,

Mark


Using javascript to read the data and insert it into the text box,
with a regular refresh sounds like the way forward. *OR* close a
textarea tag every few k of text and start a new box....

Regards,

Fuzzy

http://www.voidspace.org.uk/atlantib...thonutils.html
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by David Opstad | last post: by
16 posts views Thread by Tran Tuan Anh | last post: by
6 posts views Thread by Avi Berkovich | last post: by
4 posts views Thread by j_macaroni | last post: by
10 posts views Thread by Adrian Smith | last post: by
3 posts views Thread by Adrian Smith | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.