[Tutor] More CGI questions/incremental output

Tim Johnson tim@johnsons-web.com
Mon, 27 May 2002 08:32:32 -0800


resent: 
  NOTE: the -u option was what I was looking for.
  Many thanks to dman.
  -tj-
* dman <dman@dman.ddts.net> [020526 12:56]:
> On Sun, May 26, 2002 at 10:10:13AM -0800, Tim Johnson wrote:
> 
> Yeah, that's part of how HTTP tends to work.
> 
> | I've done other CGI programming (using Rebol, C,C++, etc)
> | and have observed output incrementally, as I would desire it.
 
  Hi dman: 

> With the same web browser?  

  Yes. I do cgi all the time with C/C++ and rebol....
  depending on the nature of the content, I'm used to seeing
  text statements displayed as they are written to stdout
  from my rebol scripts 
  result vary, of course, I won't see an table until all
  code for it is sent to the browser, but I do see simple
  text output.
   
> What about IO buffering?
  
 
> | What can I do to see an incremental output from my Python
> | script? (I am just using print to write to stdout now)
> 
> One possiblity, that also depends on your server's platform, the web
> server used, the CGI implementation in the web server and the client's
> browser (IOW not reliable by any means) is to disable python's IO
> buffering.  Run python with '-u' to disable buffering of stdout.

  That I did try just now. Didn't see a difference in that run, but
  will follow that track a bit. Thanks..

> The way "progress" is really done with HTTP is to send back a complete
> response that includes a redirect to your real processor.  
  
  Of course, will be using redirect tages for discrete stages....

> For an
> example of how this looks to the user go to orbitz.com and execute a
> search.  The first CGI script sends back that "we are processing the
> query" page which redirects to the second CGI script that does the
> actual (long) search and returns the results.  The animation is done
> via a .gif image.
 
  Do let me give you an example of a cgi script in a language that I'm
  more familiar with:

  A rebol CGI script interfaces with MySql and builds and indexes a
  large number of tables.

  At least a 100 SQL commands are issued. 
  As each command is issued, a line of text is is sent to stdout.
  It's difficult to tell exactly, because process are fairly quick,
  but my browser is giving me back at least several lines at once,
  if not one at a time.

  At that is on the same browser, web server and os.
  I will investigate the -u option further (and in fact, will be
  using redirection).

  Thanks for the explanation, and I hope to hear futher comments.

  Regards :-)
-- 
Tim Johnson <tim@johnsons-web.com>
      http://www.alaska-internet-solutions.com
      http://www.johnsons-web.com