Commit 1da7e7dd authored by Tres Seaver's avatar Tres Seaver

Forward ported 'handle_errors' fix from 2.8 branch.

parent de592be7
...@@ -42,6 +42,10 @@ Zope Changes ...@@ -42,6 +42,10 @@ Zope Changes
Bugs Fixed Bugs Fixed
- Repaired 'handle_errors' usage for doctests, along with the
supporting 'debug' argument passed to
'ZPublisher.Test.publish_module'.
- Collector #1879: applied patch by Dieter Maurer to fix a bug in - Collector #1879: applied patch by Dieter Maurer to fix a bug in
ac_aquire() ignoring the default argument ac_aquire() ignoring the default argument
......
...@@ -33,7 +33,8 @@ class Functional(sandbox.Sandboxed): ...@@ -33,7 +33,8 @@ class Functional(sandbox.Sandboxed):
__implements__ = (interfaces.IFunctional,) __implements__ = (interfaces.IFunctional,)
def publish(self, path, basic=None, env=None, extra=None, request_method='GET', stdin=None): def publish(self, path, basic=None, env=None, extra=None,
request_method='GET', stdin=None, handle_errors=True):
'''Publishes the object at 'path' returning a response object.''' '''Publishes the object at 'path' returning a response object.'''
from StringIO import StringIO from StringIO import StringIO
...@@ -77,7 +78,13 @@ class Functional(sandbox.Sandboxed): ...@@ -77,7 +78,13 @@ class Functional(sandbox.Sandboxed):
outstream = StringIO() outstream = StringIO()
response = Response(stdout=outstream, stderr=sys.stderr) response = Response(stdout=outstream, stderr=sys.stderr)
publish_module('Zope2', response=response, stdin=stdin, environ=env, extra=extra) publish_module('Zope2',
response=response,
stdin=stdin,
environ=env,
extra=extra,
debug=not handle_errors,
)
# Restore security manager # Restore security manager
setSecurityManager(sm) setSecurityManager(sm)
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
############################################################################## ##############################################################################
"""Support for (functional) doc tests """Support for (functional) doc tests
$Id: functional.py,v 1.2 2005/03/26 18:07:08 shh42 Exp $ $Id$
""" """
import sys, re, base64 import sys, re, base64
...@@ -174,9 +174,12 @@ def http(request_string, handle_errors=True): ...@@ -174,9 +174,12 @@ def http(request_string, handle_errors=True):
outstream = StringIO() outstream = StringIO()
response = Response(stdout=outstream, stderr=sys.stderr) response = Response(stdout=outstream, stderr=sys.stderr)
publish_module('Zope2', stdin=instream, publish_module('Zope2',
response=response, response=response,
environ=env) stdin=instream,
environ=env,
debug=not handle_errors,
)
header_output.setResponseStatus(response.getStatus(), response.errmsg) header_output.setResponseStatus(response.getStatus(), response.errmsg)
header_output.setResponseHeaders(response.headers) header_output.setResponseHeaders(response.headers)
......
...@@ -199,6 +199,8 @@ def publish_module(module_name, ...@@ -199,6 +199,8 @@ def publish_module(module_name,
else: must_die=sys.exc_info() else: must_die=sys.exc_info()
response.exception(1, v) response.exception(1, v)
except: except:
if debug:
raise
response.exception() response.exception()
status=response.getStatus() status=response.getStatus()
if response: if response:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment