Apache Mod-Python - Created: (MODPYTHON-100) raise apache.SERVER_RETURN, apache.OK aborts handlers.

This is Interesting: Free IT Magazines  
Home > Archive > Apache Mod-Python > December 2005 > Created: (MODPYTHON-100) raise apache.SERVER_RETURN, apache.OK aborts handlers.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Created: (MODPYTHON-100) raise apache.SERVER_RETURN, apache.OK aborts handlers.
Graham Dumpleton (JIRA)

2005-12-18, 2:45 am

raise apache.SERVER_RETURN, apache.OK aborts handlers.
------------------------------------------------------

Key: MODPYTHON-100
URL: http://issues.apache.org/jira/browse/MODPYTHON-100
Project: mod_python
Type: Bug
Components: core
Versions: 3.1.4, 3.2
Reporter: Graham Dumpleton


If multiple handlers are defined for a phase and a handler which isn't the last one, rather than returning the value apache.OK as the result, raises the apache.SERVER_RETURN exception with apache.OK as argument, then processing of subsequent handlers in t
hat phase are being aborted.

Ie., consider the example with .htaccess file of:

SetHandler mod_python
PythonHandler example::handler_1
PythonHandler example::handler_2

and example.py of:

from mod_python import apache

def handler_1(req):
apache.log_error("handler_1")
req.content_type = 'text/plain'
req.write("HELLO")
# return apache.OK
raise apache.SERVER_RETURN, apache.OK

def handler_2(req):
apache.log_error("handler_2")
return apache.OK

The expectation would be that returning the value apache.OK from the handler function and raising an exception of type apache.SERVER_RETURN with argument apache.OK would be equivalent, but they aren't. When the exception is being raised, handler_2() funct
ion is never executed.

It would seem more sensible that they are equivalent as there are other specific status values that can be used in the case that one wants to prevent further handlers in the phase from being executed. For example, as appropriate, one of:

req.status = apache.HTTP_OK
raise apache.SERVER_RETURN, apache.DONE

or:

raise apache.SERVER_RETURN, (apache.DONE,apache.HTTP_OK)

or:

raise apache.SERVER_RETURN, apache.DECLINED

To fix this, the apache.SERVER_RETURN exception should be processed within the processing loop for each handler, rather than being handled outside of the loop. The status as returned by the exception should be translated to look like it was returned by th
e handler and dealt with as for other status values returned explicitly.

No patch, perhaps wait for my rewrite of the importer for mod_python 3.3 as already addresses this issue. :-)



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com