I publish the following Modul with Bobo: Very simple: hello.py: import sys, os, time import DocumentTemplate lib=sys.path[0] sys.path.append(os.path.join(lib,'DT')) def hello(): "Display a greeting" # print "rrr" X3 = DocumentTemplate.HTMLFile(lib+'/hello.dtml') return X3() ---------------------------- Everthing works fine, when I call that method via the URL: http://myserver/cgi-bin/hello/hello --------------------------- Now, when I make the commentated line print "rrr" active, I get Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. ... This seems a little bit strange to me, because a mechanism, which works with the return values of functions should not be confused from the stdout or am I wrong (I know the cgi mechanism) ? On the other side the following doesn't work, too: ... print X3() # return X3() That means to me: stdout alone makes no sense, too. All together that would mean, I have to sustain the return value of the function which I want to publish, but I must not pollute the stdout. Now the real problem is: When I am calling same functions in that python-modul for calculations and I want to show the results in the browser, I have to take care that within the calculations nothing is written to the stdout. Is that the way I have to go ? Armin
On Wed, 13 Jan 1999, Dr. Armin Tschammer wrote:
I publish the following Modul with Bobo: Very simple:
hello.py:
import sys, os, time import DocumentTemplate
lib=sys.path[0] sys.path.append(os.path.join(lib,'DT'))
def hello(): "Display a greeting" # print "rrr" X3 = DocumentTemplate.HTMLFile(lib+'/hello.dtml') return X3()
Now, when I make the commentated line print "rrr" active, I get Internal Server Error
The "print" goes directly to the webserver, which confused it: it expects HTTP headers like "HTTP/1.0 200 Okay". The "return" sends your data to *Zope*, which then does the header stuff for you. Same with cookies, content-type, etc. Summary: dont use 'print', or redirect stdout to a log file. - j
participants (2)
-
Dr. Armin Tschammer -
John Mitchell