[Zope] Bobo or ZPublisher and stdout ( Solution: Client/Server)

Dr. Armin Tschammer Armin.Tschammer@oi42.kwu.siemens.de
Thu, 04 Mar 1999 10:49:39 +0100


Hi,

I already sent some postings to this topic, but I would like
to discuss the following problem again and how it could be solved.

Imagine there is a big C++/Python project.
The application is mainly prgrammed in C/C++ und one supports
a scritpting interface to that application via the SWIG mechanism -
the target language is Python.

During the developping process many stuff is written to the stdout -
during initialization ( before the main-function ), during execution (
in the main-function ),
and in the destructors of the static instances ( after the main-function
).

Now we want to do some web-stuff via ZPublisher, we define
a function which return a html string, which is calculated through
calling functions
from our scritpting interface of our application, that means beside my
correct
calculated string there is many stuff sent to stdout, that confuses
the Xserver and I get an error.

Ok, you would say switch the stdout to a file via calling c-funcions
like dup() or dup2( ) and
encapsulate this in a function (wrapped via SWIG), which is called in
the function which I call from
the URL in the browser.

Less cryptic:

 xy.py:

   start():
       "XXXXXXX"

        #Now all stdout goes in a file
       stdout2file( "log.txt")

        ....
       HTMLstring = ....

        # sitches the stdout back ( REVerse )
        # The way is free for CGI
        REVstdout2file()

        return HTMLstring


the URL:    http://myserver:3333/yyy/cgi-bin/xy/start

BUT with this method I have no chance to chatch stuff which is written
to the stdout
in the destrutors of the static instances, because we already have
switched back to the
"usual" stdout (for a correctly working cgi-mechnism).
The some problem one have with things which are written
to the stdout during the initialisation of the static instances.
( Imagine python itself is compiled
against a library which writes some stuff to stdout during
initialization).

I see only one solution:
If there is a ZPublisher Server process which says to a client process
do everything
and give me a calculated string via sockets or something like that, I
have not to take
care about stuff which is written to the stdout at the client process.

Or are there better solutions ?

   Thanks in advance,

    Armin