[mod_python] Publisher Handler(my own http404)

stefano cirilli stefano.cirilli1 at virgilio.it
Mon May 8 08:12:33 EDT 2006


Hi all,
i'm trying to get my own http404 page, my configuration, in apache conf file(Apache 2.0.55, mod_python 3.2.8), looks like this:
<Directory htdocs/users/http404>
SetHandler mod_python
PythonHandler mod_python.publisher
</Directory>
My Python(2.4.3) code, in a module named "pagenotf.py":

from mod_python import apache
def index(req):
	if req.filename[-17:] == 'apache-error.html':
		return(apache.HTTP_NOT_FOUND)
	if req.filename[-18:] == 'handler-error.html':
		req.status = apache.HTTP_NOT_FOUND
		pagebuffer = 'Page not here. Page left, not know where gone.'
	else:
		pagebuffer = open(req.filename, 'r').read()
	req.content_type = "text/plain"	
	req.write(pagebuffer)
	return(apache.OK)

if i send, to my browser, this URL:
http://127.0.0.1/users/http404
i receive an Http 404 response, "Page not found",
if i send
http://127.0.0.1/users/http404/pagenotf

then i get a page with the python code. Is the same, if i try

http://127.0.0.1/users/http404/pagenotf/index

How can i get(what's the URL), to display in my page, the content of the variable pagebuffer?

req.write(pagebuffer) 

sets to "Page not here. Page left, not know where gone.".
Sincerely yours,
Stefano Cirilli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20060508/35d66db0/attachment.html


More information about the Mod_python mailing list