[mod_python] help with a few basics

Dan Houtz dhoutz at advancedinterfaces.com
Wed Apr 30 14:33:40 EST 2003


Greetings,

I'm just starting to get into python and mod_python. I have installed
mod_python on Windows XP with Apache 2.0.45 to start getting my feet wet.
After some intial troubles, I believe I finally have everything working
correctly. I have managed to follow the test section and "hello world prints
properly. MY next question is, am I able to accomplish the same thing useing
print "Hello World" instead of req.write("Hello World"). I've seen many
coding examples using print, but it does not work correctly when I attempt
to use it.

For instance, this code:
	def handler(req):
	print "Content-Type: text/html\n\n"
   	print "Hello World"

Produces:
	Mod_python error: "PythonHandler mptest"

	Traceback (most recent call last):

	  File "C:\Python22\Lib\site-packages\mod_python\apache.py", line 334, in
HandlerDispatch
	    assert (type(result) == type(int())), \

	AssertionError: Handler 'mptest' returned invalid return code.


So, I tried:
	def handler(req):
	print "Content-Type: text/html\n\n"
   	print "Hello World"
	return apacke.OK

and it produced a blank page


Your help is appreciated.

Thanks,
Dan Houtz



More information about the Mod_python mailing list