473,473 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2530
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: David Opstad | last post by:
I have a question about text rendering I'm hoping someone here can answer. Is there a way of doing linguistically correct rendering of Unicode strings in Python? In simple cases like Latin or...
16
by: Tran Tuan Anh | last post by:
Dear all: I need your advice on this matter. I am working on a program which takes some pieces of System-C code in and generate some other System-C code. (System-C code is just C++ with some...
6
by: Avi Berkovich | last post by:
Hello, I was unable to use popen2.popen4 to grab python.exe's (2.3) output, for starts, it doesn't show the version information at the beginning and won't return anything when writing to the...
4
by: j_macaroni | last post by:
I know you can start php -a and go into interactive mode. This works well exept you have to keep putting <?php code here ; bla blah code ; Couple of problems with this. 1) Exits php when you...
10
by: Adrian Smith | last post by:
This may be more a cgi thing than a Python one, but I'm trying to get this page: http://adrian10.phpwebhosting.com/trial.html consisting basically of this: <FORM...
3
by: Adrian Smith | last post by:
While waiting for my paid-for web-hosting company to get back to me about my difficulties running python scripts on their servers......
4
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it...
11
by: socialanxiety | last post by:
i hope someone here can help me. basically, me and my friend have a summer project. in this project, we need something that would basically function as a blender. we know we'll need to buy a...
4
by: fordie1000 | last post by:
Hi, I have been trying to do this for a few days now ... I'd appreciate any help or insights ... Basically I want to enter text into a web 'textarea' automatically ... here is what I thought...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.