[mod_python] req.write() in publisher_handler

Mateusz Korniak mateusz at ant.gliwice.pl
Fri Aug 16 23:22:37 EST 2002

On Friday 16 August 2002 22:58, vio wrote:
> * Mateusz Korniak <mateusz at ant.gliwice.pl> [020816 15:26]:
> > Yes. But what in publisher handler case ?
> > Can you use req.write() instead of returning page ?
> > I get Internal server error in that case ... :(
> I don't quite understand your question. req.write() IS the returning page.
> But I think I know where the bobo is: it's the Internal server error
> message.

So let me be ( I hope) much more clear: Below my publisher handler:

import mod_python.apache
page = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Test page</title></head>
<body> Test </body> </html>"""

def req_write(req):
	req.status = mod_python.apache.OK
	req.content_type = "text/html; charset=utf-8"
	open("/tmp/marker","w") # Test if we have exceptions 
		#before returning from handler

def req_return(req):
	req.status = mod_python.apache.OK
	req.content_type = "text/html; charset=utf-8"
	return page

http://abbon.ant.vpn/test.py/req_return - returns what expected
http://abbon.ant.vpn/test.py/req_write returns more some additional data 
(reaching marker):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Test page</title></head>
<body> Test </body> </html>HTTP/1.1 500 Internal Server Error
Date: Fri, 16 Aug 2002 21:11:31 GMT
Server: Apache/1.3.26 (Unix)  (PLD/Linux) mod_python/2.7.8 Python/2.2.1
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

<TITLE>500 Internal Server Error</TITLE>
<H1>Internal Server Error</H1>
The server encountered an internal error or
misconfiguration and was unable to complete
your request.<P>
Please contact the server administrator,
 matkor at ant.gliwice.pl and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.<P>
More information about this error may be available
in the server error log.<P>
<P>Additionally, a 500 Internal Server Error
error was encountered while trying to use an ErrorDocument to handle the 
<ADDRESS>Apache/1.3.26 Server at <A 
HREF="mailto:matkor at ant.gliwice.pl">abbon.ant.vpn</A> Port 80</ADDRESS>

As far I understand publisher both results should be the same ...
Perhaps my mod_python /apache are broken ?

Mateusz Korniak

More information about the Mod_python mailing list