Pecan adapter: Debug mode (which returns the exception tracebacks to the
client) can be enabled by the pecan application configuration.
This commit is contained in:
parent
0fd4d50279
commit
cffcee226c
@ -17,6 +17,9 @@ next
|
||||
* Add a special type 'HostRequest' that allow a function to ask for the host
|
||||
framework request object in its arguments.
|
||||
|
||||
* Pecan adapter: Debug mode (which returns the exception tracebacks to the
|
||||
client) can be enabled by the pecan application configuration.
|
||||
|
||||
* New adapter: wsmeext.flask, for the Flask_ framework.
|
||||
|
||||
.. _Flask: http://flask.pocoo.org/
|
||||
|
@ -182,6 +182,23 @@ Pecan
|
||||
`RestController <http://pecan.readthedocs.org/en/latest/rest.html>`_
|
||||
instead of the expose decorator from Pecan.
|
||||
|
||||
Configuration
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
WSME can be configured through the application configation, by adding a 'wsme'
|
||||
configuration entry in ``config.py``:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
wsme = {
|
||||
'debug': True
|
||||
}
|
||||
|
||||
Valid configuration variables are :
|
||||
|
||||
- ``'debug'``: Wether or not to include exception tracebacks in the returned
|
||||
server-side errors.
|
||||
|
||||
Example
|
||||
~~~~~~~
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
from test.tests import FunctionalTest
|
||||
import json
|
||||
import pecan
|
||||
|
||||
|
||||
class TestWS(FunctionalTest):
|
||||
@ -92,6 +93,16 @@ class TestWS(FunctionalTest):
|
||||
a = json.loads(res.body)
|
||||
print a
|
||||
assert a['faultcode'] == 'Server'
|
||||
assert a['debuginfo'] is None
|
||||
|
||||
def test_serversideerror_with_debug(self):
|
||||
pecan.set_config({'wsme': {'debug': True}})
|
||||
res = self.app.get('/divide_by_zero.json', expect_errors=True)
|
||||
self.assertEqual(res.status, '500 Internal Server Error')
|
||||
a = json.loads(res.body)
|
||||
print a
|
||||
assert a['faultcode'] == 'Server'
|
||||
assert a['debuginfo'].startswith('Traceback (most recent call last):')
|
||||
|
||||
def test_body_parameter(self):
|
||||
res = self.app.put(
|
||||
|
@ -69,7 +69,10 @@ def wsexpose(*args, **kwargs):
|
||||
kwargs[funcdef.pass_request] = pecan.request
|
||||
result = f(self, *args, **kwargs)
|
||||
except:
|
||||
data = wsme.api.format_exception(sys.exc_info())
|
||||
data = wsme.api.format_exception(
|
||||
sys.exc_info(),
|
||||
pecan.conf.get('wsme', {}).get('debug', False)
|
||||
)
|
||||
if data['faultcode'] == 'Client':
|
||||
pecan.response.status = 400
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user