On Saturday 24 November 2001 05:39 am, Geoffrey Talvola wrote:
> On Thursday November 22, 2001 07:51 pm, Bill Bell wrote:
> > OK, I have consumed several early evening cocktails to prepare
> > myself for the embarrassment that must attend asking a question
> > like this. Here goes.
> > Please consider the following script:
> > import sys
> > sys . path . insert ( 1, r"H:\Webware" )
> > #~ import WebKit . OneShotAdapter
> > import WebKit . Object
> > print 'IMPORT SUCCEEDED'
> > Obviously I have been playing with WebWare in an effort to get my
> > head around it.
> > If I run this script just as it appears here I am unsurprised to
> > see the output from the 'print' statement. However, if I remove the
> > '#~' from that one line of the script and place it at the beginning
> > of the next line I do _not_ see the 'print' statement output.
> > What say you?
> I can certainly understand your confusion. It looks like
> OneShotAdapter.py redirects stdout immediately to a StringIO object
> as soon as it's imported. Also, there's a comment to the effect that
> "maybe this isn't the right thing to do" :-)
> OneShotAdapter is really only intended for use by OneShot.cgi -- did
> you have another use in mind, or were you just playing around?
> - Geoff
OneShotAdapter does this in order to support the OneShotAdapter.config
ShowConsole setting which forces stdout to be displayed at the end of
your web page. Without that setting, you can't see stdout which may
include some important debugging print stmts as well as the app server
Other than the confusion Bill stumbled upon, I don't think it causes
any other problems. If we didn't redirect it at the top, we'd so later
on. Doing so at the top captures as much output as possible.