[mod_python] new to mod_python, with a question.

Bill Anderson bill at immosys.com
Mon Jul 15 16:46:21 EST 2002


OK, so here is what I am doing. I am using PageTemplates (from zope) and
mod_python. or at least, I am trying to. :)


if I do _NOT_ use the request object (i.e. I return a fully formed html
string/document), it works fine. but of course, that means no use of
mod-python's request objects functions such as cookie/header
construction, usage, etc.

To wit:
def sayit(req,x=12):
	if not x:
		return "I need x"
	if not master:
		return "I need a master object"
	pt=PageTemplate()
	filestring =
"".join(open("/home/ucntcme/public_html/pythonapps/test.pt").readlines())
	pt.write(filestring)
	myx=int(x)
        req.content_type="text/html"
        req.send_http_headers()
	req.write( pt(x=myx,master=master) )
	return apache.OK

returns my rendered template, but at the bottom has:

HTTP/1.1 200 OK Date: Mon, 15 Jul 2002 22:44:27 GMT Server:
Apache/1.3.22 (Unix) (Red-Hat/Linux) mod_python/2.7.8 Python/2.2.1
mod_ssl/2.8.5 OpenSSL/0.9.6b DAV/1.0.2 PHP/4.0.6 mod_perl/1.26
Connection: close Transfer-Encoding: chunked Content-Type: text/html;
charset=iso-8859-1
OK
The server encountered an internal error or misconfiguration and was
unable to complete your request.



Debug is on, and there are no mesages in the error_log.

Now, if I just return the content using return (content), it works fine.

Why is this/what am I doing wrong here?

Cheers, Bill









More information about the Mod_python mailing list