You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-commits@quetz.apache.org by gr...@apache.org on 2006/05/03 12:49:52 UTC
svn commit: r399248 - in /httpd/mod_python/trunk: Doc/appendixc.tex
lib/python/mod_python/__init__.py lib/python/mod_python/apache.py
src/include/mpversion.h test/htdocs/tests.py test/test.py
Author: grahamd
Date: Wed May 3 03:49:48 2006
New Revision: 399248
URL: http://svn.apache.org/viewcvs?rev=399248&view=rev
Log:
When using stacked handlers and a SERVER_RETURN exception was used to
return an OK status for that handler, any following handlers weren't being
run if appropriate for the phase. (MODPYTHON-100)
The change was backported from new module importer which already included
the fix, to existing importer.
Modified:
httpd/mod_python/trunk/Doc/appendixc.tex
httpd/mod_python/trunk/lib/python/mod_python/__init__.py
httpd/mod_python/trunk/lib/python/mod_python/apache.py
httpd/mod_python/trunk/src/include/mpversion.h
httpd/mod_python/trunk/test/htdocs/tests.py
httpd/mod_python/trunk/test/test.py
Modified: httpd/mod_python/trunk/Doc/appendixc.tex
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/Doc/appendixc.tex?rev=399248&r1=399247&r2=399248&view=diff
==============================================================================
--- httpd/mod_python/trunk/Doc/appendixc.tex (original)
+++ httpd/mod_python/trunk/Doc/appendixc.tex Wed May 3 03:49:48 2006
@@ -288,6 +288,11 @@
(\citetitle[http://issues.apache.org/jira/browse/MODPYTHON-168]{MODPYTHON-168})
Fixed psp_parser error when CR is used as a line terminator in psp code.
This may occur with some older editors such as GoLive on Mac OS X.
+ \item
+ (\citetitle[http://issues.apache.org/jira/browse/MODPYTHON-100]{MODPYTHON-100})
+ When using stacked handlers and a \code{SERVER_RETURN} exception was
+ used to return an \code{OK} status for that handler, any following
+ handlers weren't being run if appropriate for the phase.
\end{itemize}
\chapter{Changes from Version (3.2.7)\label{app-changes-from-3.2.7}}
Modified: httpd/mod_python/trunk/lib/python/mod_python/__init__.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/lib/python/mod_python/__init__.py?rev=399248&r1=399247&r2=399248&view=diff
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/__init__.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/__init__.py Wed May 3 03:49:48 2006
@@ -20,5 +20,5 @@
__all__ = ["apache", "cgihandler", "psp",
"publisher", "util", "python22"]
-version = "3.3.0-dev-20060501"
+version = "3.3.0-dev-20060503"
Modified: httpd/mod_python/trunk/lib/python/mod_python/apache.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/lib/python/mod_python/apache.py?rev=399248&r1=399247&r2=399248&view=diff
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/apache.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/apache.py Wed May 3 03:49:48 2006
@@ -37,6 +37,10 @@
_path_cache = {}
_path_cache_lock = threading.Lock()
+_result_warning = """Handler has returned result or raised SERVER_RETURN
+exception with argument having non integer type. Type of value returned
+was %s, whereas expected """ + str(types.IntType) + "."
+
class CallBack:
"""
A generic callback object.
@@ -343,37 +347,52 @@
if not hlist.silent or object is not None:
- # Only permit debugging using pdb if Apache has
- # actually been started in single process mode.
-
- pdb_debug = int(config.get("PythonEnablePdb", "0"))
- one_process = exists_config_define("ONE_PROCESS")
-
- if pdb_debug and one_process:
+ try:
+ # Only permit debugging using pdb if Apache has
+ # actually been started in single process mode.
+
+ pdb_debug = int(config.get("PythonEnablePdb", "0"))
+ one_process = exists_config_define("ONE_PROCESS")
+
+ if pdb_debug and one_process:
+
+ # Don't use pdb.runcall() as it results in
+ # a bogus 'None' response when pdb session
+ # is quit. With this code the exception
+ # marking that the session has been quit is
+ # propogated back up and it is obvious in
+ # the error message what actually occurred.
+
+ debugger = pdb.Pdb()
+ debugger.reset()
+ sys.settrace(debugger.trace_dispatch)
+
+ try:
+ result = object(req)
+
+ finally:
+ debugger.quitting = 1
+ sys.settrace(None)
- # Don't use pdb.runcall() as it results in
- # a bogus 'None' response when pdb session
- # is quit. With this code the exception
- # marking that the session has been quit is
- # propogated back up and it is obvious in
- # the error message what actually occurred.
-
- debugger = pdb.Pdb()
- debugger.reset()
- sys.settrace(debugger.trace_dispatch)
-
- try:
+ else:
result = object(req)
- finally:
- debugger.quitting = 1
- sys.settrace(None)
+ except SERVER_RETURN, value:
- else:
- result = object(req)
+ # The SERVER_RETURN exception type when raised
+ # otherwise indicates an abort from below with
+ # value as (result, status) or (result, None) or
+ # result.
+
+ if len(value.args) == 2:
+ (result, status) = value.args
+ if status:
+ req.status = status
+ else:
+ result = value.args[0]
- assert (type(result) == type(int())), \
- "Handler '%s' returned invalid return code." % hlist.handler
+ assert (type(result) == types.IntType), \
+ _result_warning % type(result)
# stop cycling through handlers
if result != OK:
@@ -386,26 +405,6 @@
result = DECLINED
hlist.next()
-
- except SERVER_RETURN, value:
- # SERVER_RETURN indicates an abort from below
- # with value as (result, status) or (result, None) or result
- try:
- if len(value.args) == 2:
- (result, status) = value.args
- if status:
- req.status = status
- else:
- result = value.args[0]
-
- if type(result) != type(7):
- s = "Value raised with SERVER_RETURN is invalid. It is a "
- s = s + "%s, but it must be a tuple or an int." % type(result)
- _apache.log_error(s, APLOG_NOERRNO|APLOG_ERR, req.server)
- return HTTP_INTERNAL_SERVER_ERROR
-
- except:
- pass
except PROG_TRACEBACK, traceblock:
# Program run-time error
Modified: httpd/mod_python/trunk/src/include/mpversion.h
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/src/include/mpversion.h?rev=399248&r1=399247&r2=399248&view=diff
==============================================================================
--- httpd/mod_python/trunk/src/include/mpversion.h (original)
+++ httpd/mod_python/trunk/src/include/mpversion.h Wed May 3 03:49:48 2006
@@ -1,5 +1,5 @@
#define MPV_MAJOR 3
#define MPV_MINOR 3
#define MPV_PATCH 0
-#define MPV_BUILD 20060501
-#define MPV_STRING "3.3.0-dev-20060501"
+#define MPV_BUILD 20060503
+#define MPV_STRING "3.3.0-dev-20060503"
Modified: httpd/mod_python/trunk/test/htdocs/tests.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/test/htdocs/tests.py?rev=399248&r1=399247&r2=399248&view=diff
==============================================================================
--- httpd/mod_python/trunk/test/htdocs/tests.py (original)
+++ httpd/mod_python/trunk/test/htdocs/tests.py Wed May 3 03:49:48 2006
@@ -1088,6 +1088,13 @@
none_handler = None
+def server_return_1(req):
+ raise apache.SERVER_RETURN, apache.OK
+
+def server_return_2(req):
+ req.write("test ok")
+ return apache.OK
+
def test_sys_argv(req):
import sys
req.write(repr(sys.argv))
Modified: httpd/mod_python/trunk/test/test.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/test/test.py?rev=399248&r1=399247&r2=399248&view=diff
==============================================================================
--- httpd/mod_python/trunk/test/test.py (original)
+++ httpd/mod_python/trunk/test/test.py Wed May 3 03:49:48 2006
@@ -2058,6 +2058,25 @@
print status, rsp
self.fail("none handler should generate error")
+ def test_server_return_conf(self):
+ c = VirtualHost("*",
+ ServerName("test_server_return"),
+ DocumentRoot(DOCUMENT_ROOT),
+ Directory(DOCUMENT_ROOT,
+ SetHandler("mod_python"),
+ PythonHandler("tests::server_return_1"),
+ PythonHandler("tests::server_return_2"),
+ PythonDebug("On")))
+ return str(c)
+
+ def test_server_return(self):
+
+ print "\n * Testing SERVER_RETURN"
+ rsp = self.vhost_get("test_server_return")
+
+ if (rsp != "test ok"):
+ self.fail(`rsp`)
+
def test_publisher_conf(self):
c = VirtualHost("*",
ServerName("test_publisher"),
@@ -2548,6 +2567,7 @@
perRequestSuite.addTest(PerRequestTestCase("test_interpreter_per_directory"))
perRequestSuite.addTest(PerRequestTestCase("test_files_directive"))
perRequestSuite.addTest(PerRequestTestCase("test_none_handler"))
+ perRequestSuite.addTest(PerRequestTestCase("test_server_return"))
perRequestSuite.addTest(PerRequestTestCase("test_publisher"))
perRequestSuite.addTest(PerRequestTestCase("test_publisher_auth_nested"))
perRequestSuite.addTest(PerRequestTestCase("test_publisher_auth_method_nested"))