[mod_python] returning errors from python handler and ErrorDocument

Martin _ gzlist at googlemail.com
Sun Nov 27 17:27:15 EST 2005


In a related query to this one, is it possible to undo a raised http error?
I've not had much luck in sending 404s to a script that then creates the
resource asked for and bounces apache back to try again from the start, the
404 sticks despite my best attempts to overwrite it with a 200:

# httpd.conf
<Directory "D:/website/search">
        ErrorDocument 404 /py/404.xml
</Directory>

<Directory "D:/website/py">
        AddHandler mod_python .xml
        PythonHandler index
</Directory>

# D:/website/py/index.py
def handler(req):
        if not req.prev:
                return apache.HTTP_FORBIDDEN

        ## create relevant resource here ##

        # doesn't help # req.prev.state = apache.HTTP_OK
        # doesn't help # req.state = apache.HTTP_OK
        req.internal_redirect(req.prev.unparsed_uri)
        # doesn't help # req.next.state = apache.HTTP_OK
        # doesn't help # raise apache.SERVER_RETURN, apache.HTTP_OK
        return apache.OK

I'm open to complete rethinks here, this doesn't strike me as optimal, as
the few requests that don't want existing resources will go through three
independant handlers, but for requirements:
-I want to serve static content, even if it's generated because of that
request, as static content, not mod_python created chunked output
-I want to keep all python stuff in that /py/ dir, rather than scattering
scripts all over the tree

Any wise thoughts gratefully received,

Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20051127/4c60dba5/attachment.html


More information about the Mod_python mailing list